observability-and-logging

Implements logging, metrics, tracing, and actuator endpoints for Spring Boot REST applications.

39|3|Updated Jul 28, 2025
One-click install
npx skills add https://github.com/mzivkovicdev/spring-crud-generator --skill observability-and-logging-mzivkovicdev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: observability-and-logging
Source: https://github.com/mzivkovicdev/spring-crud-generator/tree/main/.agents/skills/observability-and-logging
Command: npx skills add https://github.com/mzivkovicdev/spring-crud-generator --skill observability-and-logging-mzivkovicdev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Spring Boot features often ship without the instrumentation needed to diagnose production failures, leaving operators with no logs, metrics, or traces when something breaks at 3 a.m. This Skill defines how to instrument Java 21+ Spring Boot REST applications so every feature is operable: structured JSON logs, correlation context, Micrometer meters, distributed tracing, and health probes. ## Core Features & Use Cases - Structured logging and correlation IDs: Configures JSON log output, MDC-based correlation filters ordered before Spring Security, and propagation to outbound HTTP clients and asynchronous work. - Metrics and tracing: Guides Micrometer meter selection, bounded tag cardinality with runtime MeterFilter caps, observations, and W3C trace propagation across service boundaries. - Operational endpoints: Covers actuator exposure on a separate management port, liveness and readiness probe groups, and safe health indicator implementation. - Use Case: When adding a scheduled job or an outbound service call to a Spring Boot application, use this Skill to add the required timers, error counters, correlation propagation, and readiness checks in the same change. ## Quick Start Use the observability-and-logging skill to add correlation ID handling, metrics, and health probes to my Spring Boot service.

Frequently Asked Questions about observability-and-logging

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

FAQPage Schema
How do I add correlation IDs to Spring Boot logs?▼

Add a OncePerRequestFilter that accepts or generates a bounded correlation ID, places it in MDC, and registers at highest precedence so it runs before the Spring Security filter chain. Clear MDC in a finally block and propagate the ID to outbound calls via a client interceptor.

How do I add Micrometer metrics to a Spring Boot service?▼

Inject MeterRegistry or ObservationRegistry and instrument operations with timers tagged by bounded outcomes. Application code depends only on Micrometer APIs; the backend is one registry dependency and one property, with HTTP, JVM, and datasource metrics coming from auto-configuration.

What is the difference between liveness and readiness probes in Spring Boot?▼

Liveness answers whether the process is broken beyond recovery and contains only livenessState. Readiness answers whether the instance can serve traffic and includes dependencies like the database. Putting an external dependency in liveness restarts every pod during a brief outage.

Why do unbounded metric tags break a monitoring backend?▼

Each distinct tag value combination creates a new time series, so tags like user IDs, emails, or raw URLs exhaust the metrics backend. Use templated routes and bounded outcomes, and back the rule with a MeterFilter that caps allowable values per tag key.

Does Spring Boot 4 change actuator probe behavior?▼

Yes. On Spring Boot 4 the liveness and readiness health groups are enabled by default, while Spring Boot 3 requires management.endpoint.health.probes.enabled: true. Keep the property explicit so behavior is identical across both generations.

When should I not add instrumentation to a Spring Boot change?▼

Instrumentation is required only by what a change introduces, such as I/O operations, outbound calls, scheduled jobs, or retry paths. A change exposing none of these, like a pure refactor or configuration rename, needs none; name any operability gap and let the requester decide.