observability

Configure Micrometer metrics, structured JSON logs, and OpenTelemetry traces for Spring Boot services.

Updated Jun 25, 2026
One-click install
npx skills add https://github.com/oriddd/ai-toolkit --skill observability-oriddd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: observability
Source: https://github.com/oriddd/ai-toolkit/tree/main/copilot/public/skills/observability
Command: npx skills add https://github.com/oriddd/ai-toolkit --skill observability-oriddd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Spring Boot services often ship without consistent metrics, logs, and traces, making production incidents hard to debug and SLOs impossible to measure. This Skill standardizes the three observability pillars so every service emits uniform, queryable signals. ## Core Features & Use Cases - Metrics with Micrometer + Prometheus: Enforces naming conventions (<service>.<domain>.<verb>), bounded tag cardinality, and correct use of Counters, Timers, and Gauges via a Filter + Recorder pattern. - Structured JSON logs with MDC: Configures Logback with logstash-logback-encoder, propagates traceId/spanId/callerId through MDC across async executors and Reactor pipelines, and defines log-level governance rules. - Distributed tracing with OpenTelemetry: Wires the Micrometer tracing bridge and OTLP exporter, sets sampling rates per environment, and standardizes W3C TraceContext propagation. - SLI/SLO conventions and dashboards as code: Defines availability, latency, and freshness targets with burn-rate alerting, plus Grafana dashboards and Prometheus alert rules stored in the repo. - Use Case: When creating a new Spring Boot microservice, apply this Skill to get production-grade metrics, JSON logs with correlation IDs, and distributed traces wired consistently from day one. ## Quick Start Apply the observability skill to wire metrics, structured logging, and tracing into my new Spring Boot service.

Frequently Asked Questions about observability

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

FAQPage Schema
How do I add Prometheus metrics to a Spring Boot service?

Add spring-boot-starter-actuator and micrometer-registry-prometheus, then record Counters, Timers, and Gauges through MeterRegistry. Use lowercase dot-separated names like foo.documents.converted and keep tag cardinality under 100 unique values.

How to propagate MDC context across async threads in Spring?

Decorate the async executor with an MdcTaskDecorator so traceId and spanId survive the thread hop in @Async or CompletableFuture work. For Mono and Flux pipelines, use Reactor Context with the MdcContextLifter pattern instead.

What sampling rate should I use for OpenTelemetry tracing in production?

Use 100% sampling in dev and staging, but around 0.05 (5%) in production, raising it temporarily per incident. Full sampling in production creates excessive storage costs and collector load.

Can I use a custom correlation header instead of traceparent?

No, you should rely on the W3C TraceContext headers traceparent and tracestate, which propagate automatically across RestClient and WebClient calls. Inventing a custom correlation header breaks interoperability with standard tracing tools.

Why should Gauges not query the database in Micrometer?

Gauges are polled frequently by Prometheus, so a heavy database query inside a Gauge would run on every scrape and overload the database. Instead, hold state in an AtomicInteger or AtomicLong updated by application code and register the Gauge once.