observability

Solid

Implement structured logging, distributed tracing, and metrics for production-ready backend services.

AI & Automation 14 stars 3 forks Updated 3 days ago MIT

Install

View on GitHub

Quality Score: 86/100

Stars 20%
39
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Observability Skill > **Expertise:** Structured JSON logging, OpenTelemetry distributed tracing, Prometheus/RED metrics, alert design. ## Structured Logging ```python import structlog import logging # Configure once at app startup structlog.configure( processors=[ structlog.contextvars.merge_contextvars, structlog.processors.add_log_level, structlog.processors.TimeStamper(fmt="iso"), structlog.processors.JSONRenderer(), # machine-parseable ], logger_factory=structlog.PrintLoggerFactory(), ) log = structlog.get_logger() # Bind context per request (FastAPI middleware) @app.middleware("http") async def logging_middleware(request: Request, call_next): request_id = request.headers.get("X-Request-ID") or str(uuid4()) structlog.contextvars.bind_contextvars( request_id=request_id, method=request.method, path=request.url.path, ) response = await call_next(request) structlog.contextvars.unbind_contextvars("request_id", "method", "path") return response # Usage in service/repository layer log.info("order.created", order_id=order.id, user_id=user.id, amount=str(order.total)) log.warning("payment.retry", order_id=order_id, attempt=attempt, reason=str(error)) log.error("db.query_failed", table="orders", query_type="insert", exc_info=True) ``` ### What NOT to log ```python # ❌ Never log PII or secrets log.info("user.login", email=user.email) # PII — omit or hash log.debug("auth.token...

Details

Author
sawrus
Repository
sawrus/agent-guides
Created
3 months ago
Last Updated
3 days ago
Language
Shell
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category