Skip to content

ComeOnOliver/skillshub / skills/aiskillstore/marketplace/0xdarkmatter/python-observability-patterns

python-observability-patterns

Verified

Observability patterns for Python applications. Triggers on: logging, metrics, tracing, opentelemetry, prometheus, observability, monitoring, structlog, correlation id.

FileKindSize
SKILL.mdskill md5.0 KB
assets/logging-config.pyscript3.2 KB
references/metrics.mdmarkdown7.5 KB
references/structured-logging.mdmarkdown7.8 KB
references/tracing.mdmarkdown8.0 KB
skill-report.jsonconfig19.1 KB

skill-report.json

View on GitHub
{
  "schema_version": "2.0",
  "meta": {
    "generated_at": "2026-01-16T14:12:38.412Z",
    "slug": "0xdarkmatter-python-observability-patterns",
    "source_url": "https://github.com/0xDarkMatter/claude-mods/tree/main/skills/python-observability-patterns",
    "source_ref": "main",
    "model": "claude",
    "analysis_version": "3.0.0",
    "source_type": "community",
    "content_hash": "f5ceb4cd93e3fe0f96ef13b1c8902326df5c88d889138e6f29f3857a139c2298",
    "tree_hash": "11933490e201f56e417ec69f08cb264505a4ffc2449feb3171c62e83b810495b"
  },
  "skill": {
    "name": "python-observability-patterns",
    "description": "Observability patterns for Python applications. Triggers on: logging, metrics, tracing, opentelemetry, prometheus, observability, monitoring, structlog, correlation id.",
    "summary": "Observability patterns for Python applications. Triggers on: logging, metrics, tracing, opentelemetr...",
    "icon": "📊",
    "version": "1.0.0",
    "author": "0xDarkMatter",
    "license": "MIT",
    "category": "devops",
    "tags": [
      "logging",
      "monitoring",
      "metrics",
      "tracing",
      "opentelemetry"
    ],
    "supported_tools": [
      "claude",
      "codex",
      "claude-code"
    ],
    "risk_factors": [
      "external_commands",
      "env_access",
      "scripts",
      "network"
    ]
  },
  "security_audit": {
    "risk_level": "safe",
    "is_blocked": false,
    "safe_to_publish": true,
    "summary": "This is a documentation-only skill containing observability patterns for Python. All static findings are FALSE POSITIVES. The scanner misinterprets Python import statements as shell commands, localhost URLs as suspicious network connections, and a security filter definition as credential access. The previous audit correctly rated this as safe with no executable code, network calls, file system access, or external commands.",
    "risk_factor_evidence": [
      {
        "factor": "external_commands",
        "evidence": [
          {
            "file": "references/metrics.md",
            "line_start": 7,
            "line_end": 50
          },
          {
            "file": "references/metrics.md",
            "line_start": 50,
            "line_end": 54
          },
          {
            "file": "references/metrics.md",
            "line_start": 54,
            "line_end": 96
          },
          {
            "file": "references/metrics.md",
            "line_start": 96,
            "line_end": 100
          },
          {
            "file": "references/metrics.md",
            "line_start": 100,
            "line_end": 147
          },
          {
            "file": "references/metrics.md",
            "line_start": 147,
            "line_end": 151
          },
          {
            "file": "references/metrics.md",
            "line_start": 151,
            "line_end": 202
          },
          {
            "file": "references/metrics.md",
            "line_start": 202,
            "line_end": 206
          },
          {
            "file": "references/metrics.md",
            "line_start": 206,
            "line_end": 245
          },
          {
            "file": "references/metrics.md",
            "line_start": 245,
            "line_end": 249
          },
          {
            "file": "references/metrics.md",
            "line_start": 249,
            "line_end": 274
          },
          {
            "file": "references/metrics.md",
            "line_start": 274,
            "line_end": 278
          },
          {
            "file": "references/metrics.md",
            "line_start": 278,
            "line_end": 313
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 7,
            "line_end": 59
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 59,
            "line_end": 63
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 63,
            "line_end": 120
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 120,
            "line_end": 124
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 124,
            "line_end": 163
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 163,
            "line_end": 167
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 167,
            "line_end": 201
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 201,
            "line_end": 205
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 205,
            "line_end": 219
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 219,
            "line_end": 223
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 223,
            "line_end": 244
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 244,
            "line_end": 248
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 248,
            "line_end": 283
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 283,
            "line_end": 289
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 289,
            "line_end": 290
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 290,
            "line_end": 291
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 291,
            "line_end": 292
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 292,
            "line_end": 296
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 296,
            "line_end": 297
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 297,
            "line_end": 298
          },
          {
            "file": "references/structured-logging.md",
            "line_start": 298,
            "line_end": 299
          },
          {
            "file": "references/tracing.md",
            "line_start": 7,
            "line_end": 36
          },
          {
            "file": "references/tracing.md",
            "line_start": 36,
            "line_end": 40
          },
          {
            "file": "references/tracing.md",
            "line_start": 40,
            "line_end": 57
          },
          {
            "file": "references/tracing.md",
            "line_start": 57,
            "line_end": 61
          },
          {
            "file": "references/tracing.md",
            "line_start": 61,
            "line_end": 96
          },
          {
            "file": "references/tracing.md",
            "line_start": 96,
            "line_end": 100
          },
          {
            "file": "references/tracing.md",
            "line_start": 100,
            "line_end": 132
          },
          {
            "file": "references/tracing.md",
            "line_start": 132,
            "line_end": 136
          },
          {
            "file": "references/tracing.md",
            "line_start": 136,
            "line_end": 160
          },
          {
            "file": "references/tracing.md",
            "line_start": 160,
            "line_end": 164
          },
          {
            "file": "references/tracing.md",
            "line_start": 164,
            "line_end": 215
          },
          {
            "file": "references/tracing.md",
            "line_start": 215,
            "line_end": 219
          },
          {
            "file": "references/tracing.md",
            "line_start": 219,
            "line_end": 239
          },
          {
            "file": "references/tracing.md",
            "line_start": 239,
            "line_end": 243
          },
          {
            "file": "references/tracing.md",
            "line_start": 243,
            "line_end": 263
          },
          {
            "file": "references/tracing.md",
            "line_start": 263,
            "line_end": 277
          },
          {
            "file": "references/tracing.md",
            "line_start": 277,
            "line_end": 278
          },
          {
            "file": "references/tracing.md",
            "line_start": 278,
            "line_end": 279
          },
          {
            "file": "references/tracing.md",
            "line_start": 279,
            "line_end": 280
          },
          {
            "file": "references/tracing.md",
            "line_start": 280,
            "line_end": 281
          },
          {
            "file": "SKILL.md",
            "line_start": 16,
            "line_end": 37
          },
          {
            "file": "SKILL.md",
            "line_start": 37,
            "line_end": 41
          },
          {
            "file": "SKILL.md",
            "line_start": 41,
            "line_end": 64
          },
          {
            "file": "SKILL.md",
            "line_start": 64,
            "line_end": 68
          },
          {
            "file": "SKILL.md",
            "line_start": 68,
            "line_end": 120
          },
          {
            "file": "SKILL.md",
            "line_start": 120,
            "line_end": 124
          },
          {
            "file": "SKILL.md",
            "line_start": 124,
            "line_end": 148
          },
          {
            "file": "SKILL.md",
            "line_start": 148,
            "line_end": 166
          },
          {
            "file": "SKILL.md",
            "line_start": 166,
            "line_end": 167
          },
          {
            "file": "SKILL.md",
            "line_start": 167,
            "line_end": 168
          },
          {
            "file": "SKILL.md",
            "line_start": 168,
            "line_end": 172
          },
          {
            "file": "SKILL.md",
            "line_start": 172,
            "line_end": 179
          },
          {
            "file": "SKILL.md",
            "line_start": 179,
            "line_end": 182
          },
          {
            "file": "SKILL.md",
            "line_start": 182,
            "line_end": 183
          },
          {
            "file": "SKILL.md",
            "line_start": 183,
            "line_end": 186
          }
        ]
      },
      {
        "factor": "env_access",
        "evidence": [
          {
            "file": "references/structured-logging.md",
            "line_start": 173,
            "line_end": 173
          }
        ]
      },
      {
        "factor": "scripts",
        "evidence": [
          {
            "file": "references/tracing.md",
            "line_start": 244,
            "line_end": 248
          }
        ]
      },
      {
        "factor": "network",
        "evidence": [
          {
            "file": "references/tracing.md",
            "line_start": 26,
            "line_end": 26
          },
          {
            "file": "references/tracing.md",
            "line_start": 114,
            "line_end": 114
          },
          {
            "file": "skill-report.json",
            "line_start": 6,
            "line_end": 6
          }
        ]
      }
    ],
    "critical_findings": [],
    "high_findings": [],
    "medium_findings": [],
    "low_findings": [],
    "dangerous_patterns": [],
    "files_scanned": 6,
    "total_lines": 1422,
    "audit_model": "claude",
    "audited_at": "2026-01-16T14:12:38.412Z"
  },
  "content": {
    "user_title": "Add Observability to Python Apps",
    "value_statement": "Python applications often lack clear logging, metrics, and tracing, making debugging difficult in production. This skill provides ready-to-use patterns for structlog, Prometheus metrics, and OpenTelemetry distributed tracing.",
    "seo_keywords": [
      "Python observability",
      "structured logging",
      "Prometheus metrics",
      "OpenTelemetry tracing",
      "Claude observability",
      "Codex monitoring",
      "Claude Code logging",
      "structlog patterns",
      "distributed tracing",
      "Python monitoring"
    ],
    "actual_capabilities": [
      "Configure structlog for production JSON logging",
      "Create Prometheus counters, histograms, and gauges",
      "Implement OpenTelemetry distributed tracing",
      "Add request context and correlation IDs to logs",
      "Build FastAPI middleware for metrics and tracing",
      "Link traces to structured logs automatically"
    ],
    "limitations": [
      "Does not include pre-built monitoring dashboards",
      "Requires external dependencies (structlog, prometheus-client, opentelemetry-api)",
      "Does not configure external observability backends"
    ],
    "use_cases": [
      {
        "target_user": "Backend Developers",
        "title": "Debug Production Issues",
        "description": "Add correlation IDs and tracing to quickly identify root cause of errors in distributed systems."
      },
      {
        "target_user": "DevOps Engineers",
        "title": "Monitor Service Health",
        "description": "Expose Prometheus metrics for dashboards and alerting on request rates, latency, and error counts."
      },
      {
        "target_user": "SRE Teams",
        "title": "Track Request Flows",
        "description": "Implement distributed tracing to visualize how requests flow across microservices."
      }
    ],
    "prompt_templates": [
      {
        "title": "Basic Logging Setup",
        "scenario": "Add structured logging to Python app",
        "prompt": "Show me how to configure structlog for production with JSON output and request context binding."
      },
      {
        "title": "HTTP Metrics",
        "scenario": "Track API performance",
        "prompt": "Create a FastAPI middleware that records request count, latency histogram, and active connections as Prometheus metrics."
      },
      {
        "title": "Distributed Tracing",
        "scenario": "Trace requests across services",
        "prompt": "Set up OpenTelemetry tracing with context propagation for a Python service that calls external APIs."
      },
      {
        "title": "Custom Span Decorator",
        "scenario": "Instrument specific functions",
        "prompt": "Write a Python decorator that wraps functions with OpenTelemetry spans and records exceptions as span events."
      }
    ],
    "output_examples": [
      {
        "input": "Add Prometheus metrics for my FastAPI endpoint that tracks request count by status code and latency by endpoint",
        "output": [
          "Define metrics at module level: REQUEST_COUNT (Counter) with labels [method, endpoint, status], REQUEST_LATENCY (Histogram) with buckets [0.01, 0.05, 0.1, 0.5, 1.0, 5.0] and labels [method, endpoint]",
          "Create middleware that increments counters before/after request and observes latency",
          "Expose /metrics endpoint that returns generate_latest() with text/plain content type"
        ]
      },
      {
        "input": "Set up structlog with a filter that removes passwords and API keys from log output",
        "output": [
          "Create a filter_sensitive_data processor that checks keys like 'password', 'token', 'secret', 'api_key', 'authorization'",
          "Recursively redact matching keys to '[REDACTED]' in nested dicts and lists",
          "Add email regex pattern to redact email addresses from log fields",
          "Insert this processor early in the chain before JSONRenderer()"
        ]
      },
      {
        "input": "How do I trace a request across multiple services with OpenTelemetry",
        "output": [
          "Use TraceContextTextMapPropagator to inject trace context into outgoing HTTP headers",
          "Extract context from incoming requests using the propagator in middleware",
          "Start spans with the extracted context to continue the trace",
          "All services must use the same propagator for trace continuity"
        ]
      }
    ],
    "best_practices": [
      "Use semantic event names (e.g., 'user_created' not 'log_message_123') for structured logs",
      "Include request_id and user_id in all log entries for debugging traceability",
      "Filter sensitive data (passwords, tokens, API keys) before logging with a processor"
    ],
    "anti_patterns": [
      "Logging sensitive data like passwords, tokens, or PII in plain text",
      "Using high cardinality labels (user_id, request_id) on Prometheus metrics",
      "Missing error context in exception logging without error type and stack trace"
    ],
    "faq": [
      {
        "question": "Which Python versions are supported?",
        "answer": "Python 3.10 and newer. Requires structlog, opentelemetry-api, and prometheus-client packages."
      },
      {
        "question": "What observability backends work with these patterns?",
        "answer": "OpenTelemetry exporters support Jaeger, Tempo, Datadog, and cloud solutions. Prometheus metrics work with any Prometheus-compatible scrape target."
      },
      {
        "question": "Can these patterns integrate with FastAPI?",
        "answer": "Yes. FastAPI instrumentation packages from OpenTelemetry work alongside the middleware patterns shown for request context and metrics."
      },
      {
        "question": "Is data sent to external services?",
        "answer": "No. The skill only provides code patterns. You configure and control all network endpoints for exporting logs and traces."
      },
      {
        "question": "Why are my metrics showing high cardinality?",
        "answer": "Avoid labels with many unique values like user_id or request_id. Use labels like method, endpoint, or status instead."
      },
      {
        "question": "How does this compare to other logging libraries?",
        "answer": "structlog provides structured logging with processors. Prometheus-client is metrics-focused. OpenTelemetry gives distributed tracing. They complement each other."
      }
    ]
  },
  "file_structure": [
    {
      "name": "assets",
      "type": "dir",
      "path": "assets",
      "children": [
        {
          "name": "logging-config.py",
          "type": "file",
          "path": "assets/logging-config.py",
          "lines": 115
        }
      ]
    },
    {
      "name": "references",
      "type": "dir",
      "path": "references",
      "children": [
        {
          "name": "metrics.md",
          "type": "file",
          "path": "references/metrics.md",
          "lines": 329
        },
        {
          "name": "structured-logging.md",
          "type": "file",
          "path": "references/structured-logging.md",
          "lines": 300
        },
        {
          "name": "tracing.md",
          "type": "file",
          "path": "references/tracing.md",
          "lines": 282
        }
      ]
    },
    {
      "name": "SKILL.md",
      "type": "file",
      "path": "SKILL.md",
      "lines": 187
    }
  ]
}
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 319kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 319kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 319kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 319kUpdated Claude CodeCodexVerifiedInstall