Springboot 3 Micrometer tracing Issue

We are using Springboot 3.1.4 and i have been trying to leverage the Micrometer based approach for distrubted tracing of the application. I have included the right build.gradle dependencies but the traces are only working for the health checkpoints and nothing else. Looking deeper I noticed a strange behavior. There are 2 flows i tested:

Flow 1 -> REST call to service 1 -> JMS Publish to service 2 method

Flow 2 -> REST call to service 2 method

In both cases, the incoming service received a PropagatedSpan with traceFlags=00. In this case no traces/spans got captured/sent.

({opentelemetry-trace-span-key=PropagatedSpan{ImmutableSpanContext{traceId=a2ea0716a45d02a490d7cef097acdb9a, spanId=adb8f982d4294b13, traceFlags=00, traceState=ArrayBasedTraceState{entries=[]}, remote=false, valid=true}}, opentelemetry-baggage-key={}, otelTraceContext=ImmutableSpanContext{traceId=a2ea0716a45d02a490d7cef097acdb9a, spanId=adb8f982d4294b13, traceFlags=00, traceState=ArrayBasedTraceState{entries=[]}, remote=false, valid=true}})

However, when the service 2 received the request from service 1 in Flow 1, it received the span as a SDKSpan with traceFlags=01. When this happens, i see the traces/spans captured for the service 2 (not service 1).

({opentelemetry-baggage-key={}, opentelemetry-trace-span-key=SdkSpan{traceId=c92ee058c19d5288d6cc72d2bb9c2a3b, spanId=5797df5b5620f02d, parentSpanContext=ImmutableSpanContext{traceId=00000000000000000000000000000000, spanId=0000000000000000, traceFlags=00, traceState=ArrayBasedTraceState{entries=[]}, remote=false, valid=false}, name=, kind=SERVER, attributes=null, status=ImmutableStatusData{statusCode=UNSET, description=}, totalRecordedEvents=0, totalRecordedLinks=0, startEpochNanos=1727214899985765169, endEpochNanos=0}, otelTraceContext=ImmutableSpanContext{traceId=c92ee058c19d5288d6cc72d2bb9c2a3b, spanId=5797df5b5620f02d, traceFlags=01, traceState=ArrayBasedTraceState{entries=[]}, remote=false, valid=true}}

Is there a way i can make the incoming trace/span to leverage SDKSpan instead of PropagatedSpan, which seems to block even the custom spans i created?

Any other way to address this issue? Thank you in advance!

SG

In Springboot 3.1.4 there’s a change only health checkpoints are traced by default. There is also this in the logs : traceFlags=00 it indicates that requests will not be traced.

I would suggest doing the following:

1- Activating sampling to trace requests and add it in your application.yml properties file :

opentelemetry:
  tracing:
    endpoint: "http://your-otel-collector:4317"
    sampling-rate: 1  # 100% of traces

2- Create tracing config and configure it with OpenTelemetry :

@Configuration
public class OpenTelemetryConfig {

@Bean
public SdkTracerProvider sdkTracerProvider() {
    // Create a span exporter (you can choose other exporters)
    OtlpGrpcSpanExporter spanExporter = OtlpGrpcSpanExporter.builder()
        .setEndpoint("http://your-otel-collector:4317")
        .setTimeout(Duration.ofSeconds(2))
        .build();

    // Configure the SDK with a batch span processor
    return SdkTracerProvider.builder()
        .addSpanProcessor(BatchSpanProcessor.builder(spanExporter).build())
        .build();
}

@Bean
public OpenTelemetry openTelemetry(SdkTracerProvider sdkTracerProvider) {
    // Initialize OpenTelemetry with the TracerProvider
    return OpenTelemetrySdk.builder()
        .setTracerProvider(sdkTracerProvider)
        .buildAndRegisterGlobal();
}

@Bean
public Tracer tracer(OpenTelemetry openTelemetry) {
    // This will create a tracer with the name of your application
    return openTelemetry.getTracer("your-application-name");
    }
}

3- Make sure tracing is propagated properly as interceptor :

@Configuration
public class RestTemplateConfig {

@Autowired
private RestTemplateBuilder restTemplateBuilder;

@Bean
public RestTemplate restTemplate() {
    TextMapPropagator propagator = GlobalOpenTelemetry.getPropagators().getTextMapPropagator();
    return restTemplateBuilder
            .additionalInterceptors((request, body, execution) -> {
                propagator.inject(Context.current(), request, (req, key, value) -> req.getHeaders().set(key, value));
                return execution.execute(request, body);
            })
            .build();
    }
}

9

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật