spring-boot-4-observability

Standardizes Logback, MDC, and Prometheus observability across Spring Boot 4 microservices.

Updated Dec 23, 2025
One-click install
npx skills add https://github.com/zuldare/apuntesIA --skill spring-boot-4-observability-zuldare
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: spring-boot-4-observability
Source: https://github.com/zuldare/apuntesIA/tree/main/skills/spring-boot-4-observability
Command: npx skills add https://github.com/zuldare/apuntesIA --skill spring-boot-4-observability-zuldare

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Spring Boot microservices within a team often end up with inconsistent logging configurations, missing request correlation IDs, and mismatched Prometheus metric tags, making cross-service debugging painful. This Skill applies one canonical observability setup to every Spring Boot 4.x / Java 25 service so logs, MDC context, and metrics look identical everywhere. ## Core Features & Use Cases - Canonical logback-spring.xml: Configures a readable console pattern for the local profile and JSON output to Logstash via an async TCP appender for all other profiles. - MDC request correlation: Creates an MdcRequestFilter that injects requestId and path into the MDC for every HTTP request, plus a mandatory JUnit test suite to verify it. - Prometheus metrics tagging: Configures the management block so every metric carries an application tag matching spring.application.name. - Optional distributed tracing: Prepares traceId and spanId MDC keys so OpenTelemetry can be activated later for Grafana Tempo or Jaeger without touching the logging config. - Use Case: When onboarding a new microservice, run this Skill to audit the existing logging state, apply the team's standard logback-spring.xml and MDC filter, and verify Prometheus metrics are correctly tagged. ## Quick Start Apply the team's standard observability setup with Logback, MDC request tracing, and Prometheus metrics to this Spring Boot 4 microservice.

Frequently Asked Questions about spring-boot-4-observability

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

FAQPage Schema
How do I standardize logging across Spring Boot microservices?▼

Create a canonical logback-spring.xml with a console appender for the local profile and an async Logstash TCP appender for other profiles. Add an MDC servlet filter that injects requestId and path per request so every log line carries correlation context.

How to add request ID tracing to Spring Boot logs with MDC?▼

Implement a servlet Filter with HIGHEST_PRECEDENCE ordering that reads the X-Request-ID header or generates a UUID, puts requestId and path into the SLF4J MDC, and clears the MDC in a finally block after the filter chain completes.

Does logback-spring.xml support Spring profiles?▼

Yes, logback-spring.xml supports springProfile and springProperty tags, unlike plain logback.xml. This lets you route logs only to console in the local profile and to both console and Logstash in all other profiles.

Why should the Logstash appender be wrapped in an AsyncAppender?▼

Wrapping LogstashTcpSocketAppender in an AsyncAppender with neverBlock=true prevents request threads from blocking when Logstash is slow or down. Without it, a Logstash outage can stall the entire service.

How do I tag Prometheus metrics with the application name in Spring Boot?▼

Set management.metrics.tags.application to ${spring.application.name} in application.yml. This adds the application tag to every metric exposed at the Prometheus endpoint without needing a custom MicrometerConfig class.

When should I enable OpenTelemetry tracing in a Spring Boot service?▼

Enable it once a Grafana Tempo or Jaeger backend with an OTLP collector is available. Adding the spring-boot-starter-opentelemetry dependency and an OTLP endpoint automatically populates traceId and spanId in the MDC for log correlation.