py-observability
Add observability to Python backends
Production issues are impossible to debug without observability. Silent failures and missing context in errors make incidents last longer. This skill provides patterns for logging, metrics, tracing, and error tracking for Python backends.
์คํฌ ZIP ๋ค์ด๋ก๋
Claude์์ ์ ๋ก๋
์ค์ โ ๊ธฐ๋ฅ โ ์คํฌ โ ์คํฌ ์ ๋ก๋๋ก ์ด๋
ํ ๊ธ์ ์ผ๊ณ ์ฌ์ฉ ์์
ํ ์คํธํด ๋ณด๊ธฐ
"py-observability" ์ฌ์ฉ ์ค์ ๋๋ค. Help me set up structured logging for my FastAPI application
์์ ๊ฒฐ๊ณผ:
- Configure structlog with JSON output for production and console renderer for development
- Add request ID correlation using contextvars middleware
- Set up proper log levels: DEBUG for diagnostics, INFO for business events, WARNING for edge cases, ERROR for failures
- Bind request context (path, method, request_id) to all logs in a request
- Redact sensitive fields like passwords and tokens before logging
"py-observability" ์ฌ์ฉ ์ค์ ๋๋ค. How do I add metrics to track API performance
์์ ๊ฒฐ๊ณผ:
- Create a Counter for total HTTP requests by method, path, and status code
- Create a Histogram for request duration with buckets (0.01, 0.05, 0.1, 0.5, 1.0, 5.0)
- Add middleware to observe request duration and increment counters
- Expose a /metrics endpoint for Prometheus scraping
- Track business metrics like submissions by skill area and status
"py-observability" ์ฌ์ฉ ์ค์ ๋๋ค. My production service is failing, how do I debug
์์ ๊ฒฐ๊ณผ:
- Generate a unique flow_id at the start of multi-step operations
- Log each step with the flow_id to trace execution path
- Include full context (user_id, assessment_id, error details) in error logs
- Use Sentry with push_scope to add custom context before capturing exceptions
- Correlate logs by request_id to see all logs from the same request
๋ณด์ ๊ฐ์ฌ
์์ All 45 static findings are false positives. This is a pure documentation skill containing only code examples for observability patterns. No executable code, network calls, filesystem access, or command execution exists. The scanner detected markdown formatting syntax and metadata hashes as security issues.
์ํ ์์ธ
๐ ๋คํธ์ํฌ ์ ๊ทผ (1)
โ๏ธ ์ธ๋ถ ๋ช ๋ น์ด (23)
๐ ํ๊ฒฝ ๋ณ์ (2)
ํ์ง ์ ์
๋ง๋ค ์ ์๋ ๊ฒ
Add logging to API endpoints
Implement structured logging with request context for FastAPI or Flask backends.
Set up monitoring dashboards
Configure Prometheus metrics and Sentry error tracking for production services.
Debug production incidents
Trace multi-step operations and correlate logs by request ID for faster debugging.
์ด ํ๋กฌํํธ๋ฅผ ์ฌ์ฉํด ๋ณด์ธ์
Help me set up structured logging using structlog for a Python FastAPI service. Include request ID correlation and proper log levels.
Show me how to add Prometheus metrics to a Python web application. Include HTTP request counters and latency histograms.
Configure Sentry error tracking for a Python backend. Include sensitive data redaction and custom context for better debugging.
Implement flow tracing for a multi-step business process in Python. Include step-by-step logging and error handling with context.
๋ชจ๋ฒ ์ฌ๋ก
- Always include request_id and user_id in logs for correlation
- Use structured key-value pairs instead of string interpolation in logs
- Log with full context when errors occur including error type and message
- Redact sensitive data before logging request bodies or user information
ํผํ๊ธฐ
- Silent early returns without logging why the function returned early
- Logging errors without context (just the error message, no user or request info)
- Using unstructured string formatting instead of structured key-value logging