Hard20 minSpring Boot Fundamentals
UpdatedAug 5, 2026
Edit

Spring Boot Observability

Question Variations

  • "Why are user IDs poor metric tags?"
  • "What is the difference between a metric and a trace?"
  • "How do you correlate an HTTP error with service logs?"

Why This Is Asked

Production debugging depends on metrics, traces, logs, and consistent correlation. This question tests whether candidates create actionable signals rather than only application logs.

Key Concepts

  • Micrometer provides metrics instrumentation and registry integration.
  • Traces connect work across service boundaries.
  • Logs need structured, safe context such as request or trace IDs.
  • High-cardinality metric tags can overload monitoring systems.

Question Variations

  • “Why are user IDs poor metric tags?”
  • “What is the difference between a metric and a trace?”
  • “How do you correlate an HTTP error with service logs?”

Answers by Technology

+ Add Variant
Spring BootImprove this answer ✏️

Expected Answer (Spring Boot 4.1.0 / Java 17+)

Use metrics for aggregate numerical signals, traces for a request’s causal path across services, and structured logs for detailed events. Spring Boot integrates Micrometer with metrics registries and observability tooling, but instrumentation needs safe cardinality: use bounded tags such as endpoint and status class, never an unbounded user ID or request ID. Propagate trace or correlation information across outbound calls and include it in logs to connect an alert to a failing request.

Why It Matters

Observable services reduce incident time-to-diagnosis without turning the monitoring system into a costly data store of unbounded labels.

Code Example

@Component
class OrderMetrics {
  OrderMetrics(MeterRegistry registry) {
    Counter.builder("orders.created").tag("channel", "api").register(registry);
  }
}

Common Mistakes

  • Using user IDs as metric tags: Cardinality grows without bound.
  • Relying only on logs: Aggregate trends and cross-service causality remain difficult to see.

Follow-up Questions

  • What is a high-cardinality tag? (Answer: A label with many or unbounded distinct values.)
  • Why propagate trace context? (Answer: It connects related operations across service boundaries.)