spring-bootspring-boot-actuatorspring-micrometer

micrometer tracing exporter autoconfiguration


Is there any autoconfiguration for OtlpGrpcSpanExporter? I see OpenTelemetryAutoConfiguration class in spring boot actuator but there's no autoconfiguration for exporter. Is it necessary to define a bean of type OtlpGrpcSpanExporter to configure trace export?

pom.xml:

<dependency>
  <groupId>io.micrometer</groupId>
  <artifactId>micrometer-tracing</artifactId>
</dependency>
<dependency>
  <groupId>io.micrometer</groupId>
  <artifactId>micrometer-tracing-bridge-otel</artifactId>
</dependency>
<dependency>
  <groupId>io.opentelemetry</groupId>
  <artifactId>opentelemetry-exporter-otlp</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

I know that spring sleuth has autoconfiguration for OtlpGrpcSpanExporter, but since spring boot 3 it migrated to micrometer, so I will use only micrometer.


Solution

  • You should be able to use OtlpTracingAutoConfiguration for this by just adding management.otlp.tracing.transport=grpc in your application.properties.

    Setting management.otlp.tracing.transport corresponds to setTransport(Transport.GRPC) which should enable the configuration of the OtlpGrpcSpanExporter (source code at the time of writing is here).

    This was initially implemented in this PR and the property is also referenced in the docs here.