Scrivio Interview library
ConceptIntermediate6 min read · updated 12 November 2026

Compare three ways to send OpenTelemetry data from a Spring Boot service: the OpenTelemetry Java agent, Micrometer Tracing with the OpenTelemetry bridge and OTLP exporter, and the OpenTelemetry Spring Boot starter. When would you choose each?

The OpenTelemetry Java agent instruments many libraries with no code changes, but it adds startup cost and is configured outside Spring with its own settings. Micrometer Tracing with the OpenTelemetry bridge uses Spring's own observations and Boot configuration and exports OTLP, for example to management.otlp.tracing.endpoint. The OpenTelemetry Spring Boot starter from the OpenTelemetry project gives OTel-native instrumentation without the agent. Pick one per service, because running two instrumentations at once creates duplicate spans.

Why this question is asked

OpenTelemetry has become the common language for telemetry, and every Spring Boot team that adopts it meets the same question on day one: there are three ways to get the data out, and they all look like they do the same thing. They do not, and the wrong choice shows up later as missing spans, duplicate spans, slow startup or configuration nobody understands. Interviewers ask this to see whether we know how each option works inside, not just its name. In this answer, we will recap the moving parts of OpenTelemetry, look at each of the three options with its setup and trade-offs, compare them side by side, and finish with how to avoid running two of them at once.

1A Quick Recap of the OpenTelemetry Parts

OpenTelemetry, or OTel, defines an API that code uses to create spans and metrics, an SDK that processes and exports them, and OTLP, the OpenTelemetry Protocol used to send them to a collector or backend. Instrumentation is the code that calls the API around libraries such as Spring MVC, JDBC or Kafka clients. The three options differ mainly in who provides that instrumentation and how it is configured.

In a Spring Boot 3 application, Spring already instruments itself with the Micrometer Observation API. So one question behind the choice is whether we want Spring's observations to be the source of our spans, or OpenTelemetry's own instrumentation.

2Option 1: The OpenTelemetry Java Agent

The agent is a jar that we attach to the JVM at startup. It rewrites the bytecode of supported libraries as they load, adding spans and metrics around them. It supports a long list of libraries out of the box, including servlet containers, JDBC drivers, HTTP clients, Kafka and many more, and we change no code at all.

Shell
java -javaagent:/otel/opentelemetry-javaagent.jar \
-Dotel.service.name=orders \
-Dotel.exporter.otlp.endpoint=http://otel-collector:4317 \
-Dotel.traces.sampler=parentbased_traceidratio \
-Dotel.traces.sampler.arg=0.1 \
-jar orders.jar
# Or the same settings as OTEL_* environment variables

The cost is that it lives outside Spring. Its settings are system properties or environment variables, not application.properties profiles, and Spring's Actuator knows nothing about them. Bytecode rewriting adds startup time, often a few seconds for a large application, which matters for scale-to-zero and short-lived jobs, and it does not work with GraalVM native images. The agent is ideal when we cannot change the code, need broad library coverage quickly, or want the same agent for many applications that are not all Spring.

3Option 2: Micrometer Tracing With the OpenTelemetry Bridge

Here Spring's own observations produce the spans. Micrometer Tracing's OTel bridge translates them into OpenTelemetry spans, and the OTLP exporter sends them out. Configuration is ordinary Boot configuration: sampling with management.tracing.sampling.probability, endpoint with management.otlp.tracing.endpoint, and metrics through Micrometer's registries, including the OTLP registry.

XML
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-otel</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp</artifactId>
</dependency>
management.tracing.sampling.probability=0.1
management.otlp.tracing.endpoint=http://otel-collector:4318/v1/traces

The strength is consistency: the same observation creates the http.server.requests timer and the span, so metrics and traces share names and tags, and our ObservationConventions shape both. It starts fast and works in native images. The limit is coverage: libraries that do not create Micrometer observations, such as a plain JDBC driver without a datasource proxy, are not traced unless we add instrumentation. This is the natural default for Spring teams that are happy with Spring's instrumentation.

4Option 3: The OpenTelemetry Spring Boot Starter

The OpenTelemetry project publishes its own starter, io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter. It uses OTel's library instrumentation, the non-agent versions of many instrumentations, wired up through Spring auto-configuration and configured with otel.* properties in application.properties. It gives OTel-native span names and attributes without attaching an agent, and it works in native images.

It covers fewer libraries than the agent, because some instrumentations need bytecode rewriting, but more than Spring's observations in some areas. It suits teams that want OpenTelemetry semantics and configuration across languages but cannot or do not want to use the agent. Spring Boot itself is also adding more OpenTelemetry support; Boot 4 introduces an OpenTelemetry starter of its own, so the names and options are moving, and we should check the documentation for the exact version we run.

5Choosing Between Them

The choice comes down to who instruments, how it is configured and what it costs at startup. A useful default is Micrometer Tracing for Spring services we own, because it keeps metrics and traces consistent and is configured like the rest of the application. The agent wins for third-party or legacy applications and when breadth of instrumentation matters more than startup time. The OTel starter fits teams that standardise on OTel semantics everywhere but need native images or no agent.

Three ways to send OpenTelemetry data
AspectJava agentMicrometer + OTel bridgeOTel Spring Boot starter
Who instrumentsAgent, by bytecode rewritingSpring's observationsOTel library instrumentation
Code changesNoneDependencies onlyDependencies only
Configurationotel.* system props, OTEL_* envmanagement.* Boot propertiesotel.* in application.properties
Library coverageWidestWhat Spring observesMedium
Startup costHigherLowLow
GraalVM native imageNoYesYes

6Avoiding Two Instrumentations at Once

The most common mistake is mixing them, for example adding the agent to a service that already has Micrometer Tracing. Both instrument the same Spring MVC request, so every request produces two server spans, often with different names, and both may write traceparent headers. Traces become confusing, span counts double, and so does the bill.

So we pick one per service and make it visible in the service's configuration. If a team needs the agent's coverage for one library, the agent can disable individual instrumentations, for example with otel.instrumentation.spring-webmvc.enabled=false, but that is a careful exception. A quick check after rollout is to look at one trace and confirm there is exactly one server span per request.

7Follow-up questions

Can metrics also go through OTLP with Micrometer?

Yes. The micrometer-registry-otlp registry sends Micrometer metrics over OTLP, and Boot configures it with management.otlp.metrics.export properties. That way traces and metrics both go to the same collector, without the agent.

Does the agent work with Micrometer metrics?

The agent has a bridge that can pick up Micrometer meters and export them through OpenTelemetry, so existing Actuator metrics are not lost. Whether it is on by default depends on the agent version, so check its documentation before relying on it.

Which option gives the best span names for dashboards?

Each follows its own conventions. Micrometer names spans from observations, such as http get /orders/{id}, while OTel instrumentation follows OpenTelemetry semantic conventions closely. On a mixed-language platform, OTel-native naming can be easier to query, which is one argument for the agent or the OTel starter.

8Conclusion

In this answer, we compared three ways to send OpenTelemetry data from Spring Boot. The Java agent instruments the most libraries with no code changes, at the cost of startup time and configuration outside Spring. Micrometer Tracing with the OTel bridge reuses Spring's observations and Boot properties, keeping metrics and traces consistent, and exports OTLP. The OpenTelemetry Spring Boot starter gives OTel-native instrumentation without the agent. Newer Boot versions add more OpenTelemetry support, so check your version, and whichever we choose, only one should instrument a service to avoid duplicate spans.

What to say in the interviewAbout 80 seconds aloud

Open with

There are three options and they differ in who does the instrumentation. The OpenTelemetry Java agent attaches with -javaagent and rewrites library bytecode, so it covers the most libraries with zero code changes.

Then, if they want more

The downside is that it's configured outside Spring with otel system properties or environment variables, adds startup time, and doesn't work in native images. I'd use it for applications I can't change, legacy apps, or when I need broad coverage quickly.

Micrometer Tracing with the OpenTelemetry bridge uses Spring's own observations, so the same observation produces the metric and the span, conventions apply to both, and it's configured with normal Boot properties like management.tracing.sampling.probability and management.otlp.tracing.endpoint. That's my default for Spring services we own. Its limit is that libraries without observations aren't traced.

The third is the OpenTelemetry project's own Spring Boot starter, which uses OTel's library instrumentation through auto-configuration and otel properties, so we get OTel-native spans without the agent and it works in native images. Boot is also adding more OpenTelemetry support, including an OpenTelemetry starter in Boot 4, so I'd check the version.

The important rule is to run only one per service, because the agent plus Micrometer gives duplicate server spans and double the cost.

About this answer

Last updated
12 November 2026
Versions it names
Spring Boot 3
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Compare three ways to send OpenTelemetry data from a Spring Boot service: the...": https://scrivio-interview-library.netlify.app/spring-boot/observability/672096967a/