Skip to content

Allow configuring Micrometer Tracing MDC keys#50595

Open
philsttr wants to merge 1 commit into
spring-projects:mainfrom
philsttr:configurable_trace_mdc_keys
Open

Allow configuring Micrometer Tracing MDC keys#50595
philsttr wants to merge 1 commit into
spring-projects:mainfrom
philsttr:configurable_trace_mdc_keys

Conversation

@philsttr
Copy link
Copy Markdown

@philsttr philsttr commented May 27, 2026

Allow the user to configure the names of the MDC keys in which the trace id and span id are stored when using Micrometer Tracing. For example, to use trace_id/span_id instead of traceId/spanId

Introduce the following new properties:

  • management.tracing.mdc.trace-id-key (default: traceId)
  • management.tracing.mdc.span-id-key (default: spanId)

The default key names keep backwards compatibility with the previously hardcoded values.

Autoconfigurations for both the Brave and OpenTelemetry Micrometer Tracing bridges honor the new properties.

Allow the user to configure the names of the MDC keys in which the trace
id and span id are stored when using Micrometer Tracing.

Introduce the following new properties:
- management.tracing.mdc.trace-id-key (default: "traceId")
- management.tracing.mdc.span-id-key  (default: "spanId")

The properties are honored by both the Brave and OpenTelemetry Micrometer
Tracing bridges.

The default key names keep backwards compatibility with the previously
hardcoded values.

Signed-off-by: Phil Clay <philsttr@users.noreply.github.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 27, 2026
@wilkinsona
Copy link
Copy Markdown
Member

Why do you want the keys to be configurable? What would configuring them allow you to do that currently isn't possible or isn't as concise as you'd like?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label May 28, 2026
@philsttr
Copy link
Copy Markdown
Author

philsttr commented May 28, 2026

Some ecosystems use trace_id/span_id. For example, python structlog and OpenTelemetry

Allowing the keys to be configurable (as supported in Micrometer Tracing) allows users to use the same names already in use in those ecosystems. This helps when enabling tracing in Spring Boot apps where a naming pattern has already been established.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants