Skip to content

Instrumentation config add traceid to http server response header #12811

@freshchen

Description

@freshchen

Is your feature request related to a problem? Please describe.

The scenario is to expect that the response header can be added quickly in the service close to the frontend without extending HttpServerResponseCustomizer

Does this requirement involve sepcs?

Describe the solution you'd like

The configuration is probably like this,default value is null

otel.instrumentation.common.http.server.tracei.header.name=X-Test-TraceId

Similar behavior to below

@AutoService(HttpServerResponseCustomizer.class)
public class TestAgentHttpResponseCustomizer implements HttpServerResponseCustomizer {

  @Override
  public <T> void customize(
      Context serverContext, T response, HttpServerResponseMutator<T> responseMutator) {

    SpanContext spanContext = Span.fromContext(serverContext).getSpanContext();
    String traceId = spanContext.getTraceId();

    responseMutator.appendHeader(response, "X-Test-TraceId", traceId);
  }
}

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestneeds triageNew issue that requires triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions