python-observability-patterns

Instrument Python 3.10+ services with structlog, OpenTelemetry, and Prometheus.

29|6|Updated Nov 27, 2025
One-click install
npx skills add https://github.com/0xDarkMatter/claude-mods --skill python-observability-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-observability-patterns
Source: https://github.com/0xDarkMatter/claude-mods/tree/main/skills/python-observability-patterns
Command: npx skills add https://github.com/0xDarkMatter/claude-mods --skill python-observability-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) and references (resource) components.

What problem does it solve?

This Skill consolidates logging, metrics, and tracing patterns to instrument Python services for operability.

Core Features & Use Cases

  • Structured logging with structlog
  • Prometheus metrics for request/DB profiling
  • OpenTelemetry tracing setup and propagation

Quick Start

Use assets/logging-config.py to configure production-ready logging and wire up a metrics endpoint.

Frequently Asked Questions about python-observability-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up structured logging with metrics and tracing for Python services?

Structured logging consolidates Python application telemetry using structlog for logs, Prometheus for metrics, and OpenTelemetry for distributed tracing. This Skill provides production-ready patterns integrating all three across FastAPI and async frameworks, enabling request correlation and context propagation without manual instrumentation overhead.

Can I use OpenTelemetry and Prometheus together in Python applications?

Yes. OpenTelemetry handles trace collection and context propagation while Prometheus scrapes metrics endpoints. This Skill combines both for Python 3.10+ services, showing how to wire structured logs, metrics, and traces into web services and background tasks with shared correlation IDs.

What's the best way to propagate request context across FastAPI endpoints and async tasks?

Request context propagation uses correlation IDs and structured logging middleware. This Skill provides FastAPI middleware and instrumentation patterns that maintain context across API endpoints and asynchronous background jobs, enabling end-to-end request tracing and correlation.

Do I need separate tools for logging, metrics, and tracing in production Python apps?

While separate, logging, metrics, and tracing work together in observability. This Skill consolidates patterns for structlog, Prometheus, and OpenTelemetry into a unified approach for Python services, reducing configuration complexity and enabling correlated insights across all three signals.

How do I instrument database and HTTP request profiling with Prometheus in Python?

Prometheus metrics capture request latency and database performance through client instrumentation. This Skill demonstrates metric patterns for profiling requests and DB operations in Python services, providing middleware and instrumentation code ready for production deployment.

What observability patterns work with both synchronous FastAPI endpoints and async background tasks?

Observability patterns must handle both sync and async contexts. This Skill covers structured logging, metrics, and tracing across FastAPI handlers and asynchronous background jobs, ensuring correlation IDs and context propagate correctly in both execution models.