0

The OTLP agent has a feature where you can add the values of request headers to a span as an attribute automatically through some configuration. How would you achieve this when using the tracing support provided by micrometer/spring boot?

The property supported by the agent is

otel.instrumentation.http.server.capture-response-headers
1
  • i'm curious if overriding getHighCardinalityKeyValues in the observation convention is the right path to go down? Commented Jul 1 at 15:30

1 Answer 1

1

You can either override the ObservationConvention or write an ObservationFilter:

@Bean
ObservationFilter headerInfoFilter() {
    return context -> {
        if (context instanceof ServerRequestObservationContext serverContext) {
            String host = serverContext.getCarrier().getHeader("Host");
            context.addHighCardinalityKeyValue(KeyValue.of("host", host != null ? host : KeyValue.NONE_VALUE));
        }
        return context;
    };
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Jonathon. Can always rely on you for a great answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.