# Add Python Observability

Python services are difficult to debug when logs, metrics, and traces are inconsistent. This skill provides practical patterns for structured logging, Prometheus metrics, Sentry setup, health checks, and redaction.

## Install

```bash
npx skillstore add cjharmath/py-observability
```

## Metadata

- Status: approved
- Slug: cjharmath-py-observability
- Skillstore revision: r1
- Version status: missing
- Tree hash: cffe97e5858393160bb03c713d49f15b7813be0abbe68349192717039f0790a8
- Author: CJHarmath
- GitHub username: CJHarmath
- License: MIT
- Repository: https://github.com/CJHarmath/claude-agents-skills/tree/main/skills/py-observability
- Ref: dd4a3ef9f20ddf38830950b4bb713df96b431fd6
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, env\_access
- Quality score: 68
- Public page: https://skillstore.pages.dev/skills/cjharmath-py-observability
- Manifest: https://skillstore.pages.dev/api/skills/cjharmath-py-observability/manifest

## Capabilities

- Shows structlog patterns for JSON logs and request context correlation.
- Defines Prometheus counters, histograms, gauges, and a metrics endpoint.
- Demonstrates Sentry setup with FastAPI and SQLAlchemy integrations.
- Provides examples for health and readiness endpoints in FastAPI.
- Includes patterns for redacting sensitive request data before logging.
- Gives a checklist for production debugging and feature instrumentation.

## Use Cases

- Instrument a FastAPI Service: Add request IDs, structured logs, metrics, and readiness checks to a Python backend.
- Improve Incident Debugging: Make failures easier to trace with contextual logs, flow IDs, and Sentry events.
- Review Observability Coverage: Use the checklist to find missing logs, metrics, redaction, and health checks before release.

## Prompt Templates

### Add Basic Logging

```
Use the py-observability skill to add structured logging to this Python endpoint. Include request context and useful event names.
```

### Add Metrics

```
Use the py-observability skill to add Prometheus metrics for this FastAPI route. Include request duration and success or failure counters.
```

### Prepare Production Debugging

```
Use the py-observability skill to instrument this multi-step workflow. Add flow tracing, error context, metrics, and sensitive data redaction.
```

### Audit Observability Design

```
Use the py-observability skill to review this service for observability gaps. Identify missing logs, metrics, traces, health checks, and privacy risks.
```

## Limitations

- Provides reference patterns, not a complete observability platform.
- Examples require adaptation to each application framework and data model.
- Does not configure dashboards, alert rules, or infrastructure deployment.
- Some privacy examples need stricter controls before use in regulated systems.

## Best Practices

- Use stable event names and structured fields instead of formatted log messages.
- Redact secrets and personal data before sending logs or error events.
- Add metrics and health checks beside the code paths they describe.

## Anti Patterns

- Do not log raw request bodies, credentials, tokens, or authorization headers.
- Do not expose detailed dependency errors from public health endpoints.
- Do not add high-cardinality labels such as user IDs to Prometheus metrics.

## Security Audit

- Audited at: 2026-07-06T06:40:58.953\+00:00
- Summary: Static findings for external commands, environment access, and reconnaissance are false positives caused by Markdown code fences, redaction key names, and request correlation examples. No prompt injection or malicious executable behavior was found in SKILL.md. Semantic review found privacy and information disclosure risks in the Sentry user context and readiness endpoint examples.

## Stats

- Views: 261
- Downloads: 9
- Favorites: 0
- Popularity score: 0
