kid-sid/claude-spellbook/observability
Claude Code and agent skill by kid-sid/claude-spellbook
- community
Checking that the SKILL.md file is still in the repository.
Use when adding structured logging, instrumenting Prometheus metrics, wiring up distributed tracing with OpenTelemetry, writing alerting rules, defining SLOs and error budgets, or building a Grafana golden-signals dashboard.
Install
npx vskill@latest install kid-sid/claude-spellbook/observabilitySKILL.md
The same SKILL.md was published earlier as kid-sid/claude-spellbook/observability.
Observability
Observability is the practice of instrumenting systems so you can understand their internal state from external outputs — logs, metrics, and traces.
When to Activate
- Adding logging to a new service or endpoint
- Setting up Prometheus metrics for a service
- Implementing distributed tracing across services
- Writing alerting rules or on-call runbooks
- Defining SLOs and error budgets for a service
- Building a Grafana dashboard for a service
- Debugging a production issue using logs, metrics, or traces
The Three Pillars
| Pillar | Question it answers | Best tool | When to reach for it | |
|---|---|---|---|---|
| Logs | "What happened?" | structlog, pino, slog | Debugging specific errors, audit trails | |
| Metrics | "How is the system performing?" | Prometheus | Trending, alerting, capacity | |
| Traces | "Why is this slow / where did it fail?" | OpenTelemetry | Latency debugging, distributed request flow |
OpenTelemetry is the unifying standard across all three pillars: one SDK for logs, metrics, and traces, vendor-agnostic, with exporters to any backend (Grafana, Datadog, Honeycomb, Jaeger, etc.).
Structured Logging
Always emit logs as JSON. Human-readable plaintext is fine in development, but production logs must be machine-parseable. Never log sensitive data (PII, card numbers, passwords, tokens).
Mandatory Fields
Every log line must include:
| Field | Type | Example | |
|---|---|---|---|
timestamp | ISO 8601 | 2024-01-15T10:30:00.000Z | |
level | string | INFO | |
service | string | payment-service | |
trace_id | string | abc123... | |
span_id | string | def456... | |
request_id | string | UUID per HTTP request | |
message | string | Human-readable description |
Log Levels
| Level | When to use | Example | |
|---|---|---|---|
| DEBUG | Verbose dev-only detail | "Entering validatePayment()" | |
| INFO | Normal operational events | "Payment processed for order 123" | |
| WARN | Unexpected but recoverable | "Retry attempt 2/3 for order 123" | |
| ERROR | Failure that needs attention | "Payment declined: card expired" | |
| FATAL/CRITICAL | Service cannot continue | "DB connection pool exhausted" |
Rule: use INFO in production, DEBUG only in development. WARN does not page on-call. ERROR does.
Code Examples
Python with structlog:
TypeScript with pino:
Go with slog (stdlib, Go 1.21+):
Correlation ID Propagation
Correlation IDs let you follow a single request across multiple services and log entries.
- Generate
request_idat the edge (API gateway or the first handler to receive the request) - Pass it downstream via HTTP headers:
X-Request-IDorX-Correlation-ID - Include the ID in all log lines for the duration of that request
- Include the ID in error responses so users can report it to support
- In async flows (message queues, event streams): embed
correlation_idin the message payload itself, not just headers
Middleware pattern (Express/Node):
Middleware pattern (Python/FastAPI):
Metrics with Prometheus
Prometheus is a pull-based metrics system: your service exposes a /metrics endpoint and Prometheus scrapes it on a configured interval (typically 15–30 seconds).
Metric Types
| Type | Use for | Example | |
|---|---|---|---|
| Counter | Things that only go up (requests, errors) | http_requests_total | |
| Gauge | Values that go up and down | active_connections, memory_bytes | |
| Histogram | Distribution of values (latency, size) | request_duration_seconds | |
| Summary | Like histogram, but calculates quantiles client-side | Avoid — prefer Histogram |
Prefer Histogram over Summary. Histograms can be aggregated across instances in PromQL; Summaries cannot.
Naming Conventions
Pattern: <namespace>_<subsystem>_<name>_<unit>
payment_service_http_requests_total— counter;_totalsuffix implies countpayment_service_db_query_duration_seconds— histogram; always include unit in the namepayment_service_cache_hit_ratio— gauge; ratio 0–1, no unit suffix neededpayment_service_queue_depth— gauge; current number of items in queue
Never include label values in metric names. Use labels instead:
Label Cardinality Trap
Labels multiply time series. A metric with two labels each having 10 values creates 100 series. High-cardinality labels (user IDs, order IDs, full URL paths with path parameters) can create millions of series, crashing Prometheus.
Safe label values: HTTP method, endpoint (normalized, no IDs), status code, region, environment, service version.
RED Method (for services)
Use RED to define the minimum set of metrics for any service:
- Rate: requests per second
``promql rate(http_requests_total[5m]) ``
- Errors: error rate as a fraction of total traffic
``promql rate(http_requests_total{status=~"5.."}[5m]) / rate(http_requests_total[5m]) ``
- Duration: latency at the 95th percentile
``promql histogram_quantile(0.95, rate(request_duration_seconds_bucket[5m])) ``
USE Method (for resources)
Use USE to define metrics for infrastructure and resource-level components:
- Utilization: percentage of time the resource is busy (e.g., CPU%, disk I/O%)
- Saturation: work that is queued because it cannot be served immediately (e.g., run queue length)
- Errors: error events from the resource (e.g., disk I/O errors, network drops)
Code Examples
Python with prometheus_client:
TypeScript with prom-client:
Go with prometheus/client_golang:
Distributed Tracing with OpenTelemetry
Concepts
- Trace: the complete end-to-end journey of a single request, identified by a unique
trace_id - Span: a single named unit of work within a trace (has a start time, end time, status, and attributes); spans form a tree
- Context propagation: the mechanism for passing
trace_idandspan_idacross service boundaries via HTTP headers; use the W3Ctraceparentheader (standardized, supported everywhere) - Collector: a sidecar or standalone service (otel-collector) that receives span data, batches it, and forwards it to a backend (Jaeger, Tempo, etc.)
Auto-Instrumentation vs Manual Spans
- Auto-instrumentation: instrument HTTP frameworks, DB drivers, gRPC clients automatically — get traces with zero code changes (install the SDK + one setup file)
- Manual spans: wrap custom business logic to make it visible in traces (e.g., "processing payment", "calling fraud check API", "serializing response")
When in doubt: start with auto-instrumentation to get baseline visibility, then add manual spans where you need business context.
Setup (Python)
Setup (TypeScript)
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/observability/skill.md
Popularity
- Repository stars
- 186
- Repository forks
- 15
- 7-day trend score
- 26
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/kid-sid/claude-spellbook/observability)