Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instrumentation config add traceid to http server response header #12811

Open
freshchen opened this issue Nov 28, 2024 · 0 comments
Open

Instrumentation config add traceid to http server response header #12811

freshchen opened this issue Nov 28, 2024 · 0 comments
Labels
enhancement New feature or request needs triage New issue that requires triage

Comments

@freshchen
Copy link

freshchen commented Nov 28, 2024

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

@freshchen freshchen added enhancement New feature or request needs triage New issue that requires triage labels Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs triage New issue that requires triage
Projects
None yet
Development

No branches or pull requests

1 participant