OpenTelemetry Fundamentals + Spring Boot Integration
Fast recall
Quick revision
Core answer
-javaagent:opentelemetry-javaagent.jar for zero-code auto-instrumentation, OR use the Spring Boot Starter for more control. Configure via environment variables (OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_SERVICE_NAME). Manual instrumentation via Tracer and Meter APIs for business-specific spans. Export to an OTel Collector for flexibility.Understanding of OpenTelemetry's role as vendor-neutral instrumentation standard
Treating OTel as a backend; it's an SDK and protocol, not a storage system
Discuss OTel Collector pattern, attributes vs events vs links, resource detection, semantic conventions, and vendor lock-in reduction
Interview-ready guide
Interview answer
OpenTelemetry is the CNCF vendor-neutral standard for application instrumentation. One SDK, one set of APIs, exportable to any backend — Datadog, Grafana Tempo, Jaeger, New Relic, Honeycomb. Covers traces, metrics, and logs.
The value proposition
- Instrument once, export anywhere
- Before OTel, every APM had its own agent; switching vendors meant rewriting instrumentation
- OTel solves lock-in; every major APM now consumes OTLP (its wire protocol)
- As of 2026: traces stable, metrics stable, logs maturing
Three integration paths for Spring Boot
Java Agent (easiest, zero-code)
- Download opentelemetry-javaagent.jar; launch with -javaagent flag
- Auto-instruments Spring MVC, Spring WebFlux, JDBC, HTTP clients, Kafka, Redis, MongoDB
- Configure via env vars: OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_ENDPOINT
- Start here for any new service; minimal effort, big coverage
Spring Boot Starter (more control)
- Add opentelemetry-spring-boot-starter dependency
- Configure via application.yml; integrates with Spring auto-config
- Plays well with Actuator and Micrometer
Manual SDK (most control)
- Build OpenTelemetrySdk programmatically; wire up TracerProvider, exporters, samplers
- Use for custom setups or when the agent isn't an option
Manual instrumentation for business spans
- Auto covers HTTP, DB, messaging — but your domain logic needs explicit spans
- Use Tracer API: spanBuilder, setAttribute, makeCurrent, recordException, end
- Wrap in try-with-resources (Scope) and try/catch/finally pattern
- Add business attributes: payment.id, customer.region, order.total
The Collector is the fanout/processing proxy
- Receives OTLP from apps; processes (batch, sample, scrub); exports to one or more backends
- Tail-based sampling: decide what to keep after seeing the full trace
- PII scrubbing: strip sensitive fields before sending to third-party backends
- Multi-backend: send to Datadog and Grafana Tempo simultaneously for migration or redundancy
- Deploy as sidecar, DaemonSet, or gateway; gateway mode is most common at scale
Semantic conventions matter
- OTel defines standard attribute names: http.request.method, db.system, messaging.destination
- Backends have pre-built dashboards expecting these names
- Deviating means rebuilding dashboards — stick to conventions
Sampling strategy
- Default: 10% head-based plus force-sample-on-error plus tail-based in Collector
- Balances cost and debug value
- Tail-based keeps errors and slow traces preferentially
What to avoid
- Don't run OTel Java Agent and vendor agent simultaneously — duplicate instrumentation, broken traces
- Don't rip out mature vendor instrumentation to adopt OTel for purity — migrate incrementally
- Don't ignore cardinality; OTel doesn't save you from bad label design
The strategic answer
- OTel is the portability bet for 3+ year architecture
- Start with Java Agent for new services; zero-code, broad coverage
- Add manual instrumentation for business-domain spans
- Deploy a Collector for flexibility and processing
- Export to whichever backend fits your cost/feature needs; can change later
OpenTelemetry Fundamentals + Spring Boot Integration
Direct Answer
OpenTelemetry (OTel) is the CNCF vendor-neutral standard for instrumentation — one SDK, one set of APIs, exportable to any backend (Datadog, Grafana Tempo, Jaeger, New Relic, Honeycomb). Covers traces, metrics, and logs. For Spring Boot: add the OpenTelemetry Java Agent as -javaagent:opentelemetry-javaagent.jar for zero-code auto-instrumentation, OR use the Spring Boot Starter for more control. Configure via environment variables (OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_SERVICE_NAME). Manual instrumentation via Tracer and Meter APIs for business-specific spans. Export to an OTel Collector for flexibility.
Common Mistakes & Pitfalls
Treating OTel as a backend; it's an SDK and protocol, not a storage system
Check your understanding
Answer these without looking back at the article.
- What is the OpenTelemetry Collector and when do you need it in your architecture?
- How do OpenTelemetry semantic conventions reduce dashboard rework?
- What's the relationship between OTel and Micrometer in Spring Boot?
- How does OTel handle context propagation across async code and thread boundaries?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.