Spring Boot otel.propagators

Cloud TunedCloud Tuned
2 min read

Introduction

In Spring Boot applications utilizing OpenTelemetry for distributed tracing, otel.propagators is a configuration property used to specify which context propagation formats OpenTelemetry should use.

W3C Trace Context

The tracecontext value for otel.propagators specifically refers to the W3C Trace Context specification. This is the recommended and default propagation format for OpenTelemetry. It defines a standard way to propagate trace and span IDs across service boundaries using HTTP headers, primarily traceparent and tracestate.

How it works in Spring Boot:

  • Instrumentation:

    When OpenTelemetry instrumentation is enabled in your Spring Boot application (e.g., through the OpenTelemetry Spring Boot Starter), it automatically intercepts incoming and outgoing requests.

  • Extraction:

    For incoming requests, OpenTelemetry extracts the trace context information (trace ID, span ID, sampling state, etc.) from the traceparent and tracestate headers (if present). This extracted context is then made available to the current execution thread.

  • Injection:

    For outgoing requests (e.g., HTTP calls to other services), OpenTelemetry injects the current trace context into the traceparent and tracestate headers of the outgoing request. This ensures that the downstream service receives the necessary information to continue the trace.

Configuration:

You can configure otel.propagators in your application.properties or application.yml file:

otel.propagators=tracecontext,baggage
otel:
  propagators: tracecontext,baggage

In this example, tracecontext is specified, along with baggage, which is another common propagation format used for propagating arbitrary key-value pairs across services.

Conclusion

By using otel.propagators=tracecontext, you ensure that your Spring Boot application properly participates in distributed traces, allowing for end-to-end visibility of requests across multiple services.

0
Subscribe to my newsletter

Read articles from Cloud Tuned directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Cloud Tuned
Cloud Tuned