Open Telemetry Instrumentation for Non java-agent Instrumented Spring Boot Apps

I found a solution to the problem…

Turns out you have to explicitly inject the tracer and context propagator into the OpenTelemetrySpanFactory and apply the configuration across all apps…

import io.opentelemetry.api.trace.Tracer
import io.opentelemetry.context.propagation.TextMapPropagator
import org.axonframework.tracing.SpanFactory
import org.axonframework.tracing.opentelemetry.OpenTelemetrySpanFactory
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class AxonConfig {

    @Bean
    fun spanFactory(tracer: Tracer, contextPropagator: TextMapPropagator): SpanFactory =
        OpenTelemetrySpanFactory
            .builder()
            .tracer(tracer)
            .contextPropagators(contextPropagator)
            .build()
}
1 Like