Skip to content

github/awesome-copilot / skills/spring-observability

spring-observability

Verified

Add and review observability in Spring Boot 3/4 apps: Actuator exposure and health probes, Micrometer metrics, Observation API, OpenTelemetry tracing and OTLP/Prometheus export, structured logging with correlation ids, and safe use of heapdump/threaddump. Use when instrumenting, monitoring or troubleshooting a Spring Boot service.

FileKindSize
SKILL.mdskill md3.7 KB
references/actuator.mdmarkdown1.9 KB
references/dumps-and-diagnostics.mdmarkdown1.4 KB
references/logging.mdmarkdown1.7 KB
references/metrics.mdmarkdown2.0 KB
references/tracing-observation.mdmarkdown2.7 KB

references/metrics.md

View on GitHub
# Micrometer metrics

Boot auto-configures a composite `MeterRegistry` plus a registry for each `micrometer-registry-*` found on the classpath.

## Export

- Prometheus scrape: add `io.micrometer:micrometer-registry-prometheus` (version managed by Boot) and expose `prometheus`. Endpoint: `/actuator/prometheus`.
- OTLP push: `io.micrometer:micrometer-registry-otlp`, then `management.otlp.metrics.export.url=http://collector:4318/v1/metrics`. With Boot 4 `spring-boot-starter-opentelemetry` also provides OTLP export of metrics, traces and logs, check the Boot reference for current properties.
- Disable all exporters in tests: `management.defaults.metrics.export.enabled=false`.

## Common tags

```java
@Bean
MeterRegistryCustomizer<MeterRegistry> commonTags(@Value("${spring.application.name}") String app) {
    return r -> r.config().commonTags("application", app);
}
```

(Package: Boot 3.x `org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer`; Boot 4.x `org.springframework.boot.micrometer.metrics.autoconfigure.MeterRegistryCustomizer`.) Alternatively `management.metrics.tags.application=${spring.application.name}`.

## Custom metrics

```java
Counter.builder("orders.created").tag("channel", "web").register(registry).increment();
Timer.builder("orders.processing").publishPercentileHistogram().register(registry).record(() -> process());
Gauge.builder("orders.queue.size", queue, Queue::size).register(registry);
```

- Use `@Timed`/`@Counted` only with the `TimedAspect`/`CountedAspect` beans and AOP present.
- Keep tag cardinality bounded (never user ids, raw URLs, exception messages).
- HTTP server metrics: `http.server.requests` is on by default; enable histograms with `management.metrics.distribution.percentiles-histogram.http.server.requests=true`.
- JVM, DB pool (HikariCP), cache, Kafka and executor metrics are automatic when present.

## Testing

Use `SimpleMeterRegistry` in unit tests, and `@AutoConfigureObservability` (or enable export explicitly) in slices that disable metrics by default.
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: 321kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 321kUpdated 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: 321kUpdated 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: 321kUpdated Claude CodeCodexVerifiedInstall