0

im using

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-sleuth-zipkin</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
        </dependency>

and jaeger to collect and show spans enter image description here

on screenshot only info myapp-app: get be4eed3 but it makes hard to investigate and find some particular method.

How to customize it to ${method name in controller} and add some additional info ?

Dmitry Shabalin
  • 141
  • 1
  • 9

1 Answers1

1

You can Inject a SpanHandler bean and change the span name to the controller method name:

        @Bean
        SpanHandler spanHandler() {
            return new SpanHandler() {
                @Override
                public boolean end(TraceContext traceContext, MutableSpan span, Cause cause) {
                    String operation = span.tags().getOrDefault("mvc.controller.method", null);
                    if(operation != null) {
                        span.name(operation);
                    }
    
                   
                    return true;
          }
      }
Mohamed Ali RACHID
  • 3,245
  • 11
  • 22
  • yes it works ``` @Override public boolean end(TraceContext traceContext, MutableSpan span, Cause cause) { Map tags = span.tags(); if(tags.get("http.path") != null){ span.name(tags.get("http.method") + " " + tags.get("http.path")); } return true; } }; ``` – Dmitry Shabalin May 25 '23 at 15:03