question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sleuth not reporting client spans with Feign builder

See original GitHub issue

First if you think this issue would have been better in StackOverflow or other then forgive me and tell it so I’ll know for next time.

Describe the bug When using Feign.builder() to create a BuilderFeign build with ribbon client LoadBalancerFeignClient I notice that the client spans are not sent to zipkin.

I noted the documentation saying ‘nothing created manually will work’ yet I see some instrumentation.

TraceFeignObjectWrapper.wrap handles LoadBalancerFeignClient and - from my understanding - TraceLoadBalancerFeignClient creates a span - that should be sent downstream - and abandon it at the end. On the other hand, for other feign clients, TracingFeignClient performs the receive.

Given the specific code I suppose there is a rational behind this choice but I do not understand it. Could you explain it?

I managed to have my client reporting client spans by creating a class that extends TraceLoadBalancerFeignClient and mimic the content of TracingFeignClient but I’m surprised that this is needed.

Sample A sample app with these classes reproduces the behavior:

public interface BuilderFeign {
    @RequestLine("GET /")
    String pingGithub();
}
@Configuration
public class BuilderFeignConfig {

    @Bean
    static BuilderFeign blotterFeignClient(ObjectFactory<HttpMessageConverters> messageConverters,
                                           Client loadBalancerFeignClient){
        Request.Options options = new Request.Options(30000, 30000);

        return Feign.builder()
                .encoder(new SpringEncoder(messageConverters))
                .decoder(new SpringDecoder(messageConverters))
                .decode404()
                .retryer(NEVER_RETRY)
                .options(options)
                .client(loadBalancerFeignClient)
                .target(BuilderFeign.class, "https://api.github.com");
    }

    @Bean
    public Client loadBalancerFeignClient(CachingSpringLoadBalancerFactory cachingFactory,
                                               SpringClientFactory clientFactory, BeanFactory beanFactory,
                                               HttpTracing httpTracing) {
        PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
        cm.setMaxTotal(200);
        cm.setDefaultMaxPerRoute(20);
        return new LoadBalancerFeignClient(new Client.Default(null, NoopHostnameVerifier.INSTANCE), cachingFactory, clientFactory);
// client spans are reported with this implementation
//        return new CustomTraceLoadBalancerFeignClient(httpTracing, new Client.Default(null, NoopHostnameVerifier.INSTANCE), cachingFactory, clientFactory, beanFactory);
    }
}
    @GetMapping("/builderFeign")
    public ResponseEntity<?> getFromBuilderFeign() {
        return new ResponseEntity<>(this.builderFeign.pingSgithub(), HttpStatus.OK);
    }

My class CustomTraceLoadBalancerFeignClient is a copy of TracingFeignClient + other needed copies (due to closed visibility) except the call to this.delegate.execute(modifiedRequest(request, headers), options) is replaced by super.execute(modifiedRequest(request, headers), options)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
natremcommented, Jul 30, 2020

My bad. While creating the sample free of corporate stuff I found out I did not test properly earlier. The client spans are now reported correctly with latest versions. Thanks.

0reactions
marcingrzejszczakcommented, Jul 30, 2020

Can you create a sample with your code?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Feign builder requests doesn't send trace-id, span-id to ...
Using Feign builder requests doesn't send trace-id, span-id to child clients but using rest template is showing all headers on child clients.
Read more >
Spring Cloud Sleuth
cr - Client Received - Signifies the end of the span. The client has successfully received the response from the server side.
Read more >
Span (Spring Cloud Sleuth Core 1.2.3.RELEASE API)
Class for gathering and reporting statistics about a block of execution. ... When non-zero, the trace containing this span uses 128-bit trace identifiers....
Read more >
Tracing a Reactive Kotlin App with Spring Cloud Sleuth
spanBuilder () .kind(Span.Kind.CLIENT) ...
Read more >
Tracing In Microservices With Spring Cloud Sleuth - Ryan Baxter
The span ID represents a basic unit of work, for example sending an HTTP request. The trace ID contains a set of span...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found