observability
SKILL.md
observability
Structured observability patterns for Python APIs using Logfire and OpenTelemetry.
Overview
Use Logfire for fast setup and OpenTelemetry for vendor-neutral exports. Always set service metadata, instrument key frameworks (FastAPI/httpx), and control sampling.
When to Use
- Tracing API requests and dependencies
- Capturing structured logs with context
- Exporting telemetry to OTLP collectors
Quick Start
uv pip install logfire
import logfire
from fastapi import FastAPI
app = FastAPI()
logfire.configure(service_name="backend")
logfire.instrument_fastapi(app)
logfire.instrument_httpx()
Core Patterns
- Service metadata: set
service_nameand environment. - Automatic instrumentation: FastAPI + httpx for request spans.
- Structured logs: include request IDs and user context.
- Sampling: reduce volume for high-traffic services.
- OTLP exports: keep backends swappable.
OpenTelemetry Export Example
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
resource = Resource(attributes={"service.name": "service"})
trace.set_tracer_provider(TracerProvider(resource=resource))
tracer = trace.get_tracer(__name__)
exporter = OTLPSpanExporter()
trace.get_tracer_provider().add_span_processor(BatchSpanProcessor(exporter))
with tracer.start_as_current_span("healthcheck"):
pass
Troubleshooting
- Missing service name: spans hard to find in UI
- High-cardinality attributes: explode storage
- No spans: instrumentation called too late
References
Weekly Installs
2
Repository
jiatastic/open-…n-skillsGitHub Stars
3
First Seen
Jan 24, 2026
Installed on
claude-code2
github-copilot1