Search code examples
amazon-web-servicestracezipkinaws-xray

How do I map http_path in zipkin to AWS XRay request URL


I send my traces to Zipkin and I can tell I am setting the HTTP Path enter image description here

But it does not map to XRay's Request URL.
enter image description here

Where can I do the mapping?

I am using the following images as per my answer on integrating Spring Cloud Sleuth with Amazon X-Ray

  • amazon/aws-xray-daemon:latest
  • ghcr.io/openzipkin/zipkin-aws:latest

Looking through the code, I am using HttpTracing from ZipKin brave libraries I am presuming that's what it is using to populate the data.

Digging around some more there seems to be an openzipkin/zipkin-aws#58 which sort of describes the issue


Solution

  • Looking through the code I may just need to alter the default tracing to add the additional details. Adding the following bean will make it configure to contain the necessary details.

    @Bean
    public HttpTracing httpTracing(Tracing tracing) {
    
        return HttpTracing.newBuilder(tracing)
            .serverRequestParser(
                (req, context, span) -> {
                    HttpRequestParser.DEFAULT.parse(req, context, span);
                    HttpTags.URL.tag(req, context, span);
                }
            )
            .serverResponseParser(
                ((response, context, span) -> {
                    HttpResponseParser.DEFAULT.parse(response, context, span);
                    HttpTags.STATUS_CODE.tag(response, span);
                })
            )
            .clientRequestParser(
                (req, context, span) -> {
                    HttpRequestParser.DEFAULT.parse(req, context, span);
                    HttpTags.URL.tag(req, context, span); // add the url in addition to defaults
                }
            )
            .clientResponseParser(
                ((response, context, span) -> {
                    HttpResponseParser.DEFAULT.parse(response, context, span);
                    HttpTags.STATUS_CODE.tag(response, span);
                })
            )
            .build();
    
    }