Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Autoconfiguration order issue in 2.1.0 using Sleuth #109

Open
atsharp opened this issue Apr 17, 2021 · 0 comments
Open

Autoconfiguration order issue in 2.1.0 using Sleuth #109

atsharp opened this issue Apr 17, 2021 · 0 comments
Assignees

Comments

@atsharp
Copy link

atsharp commented Apr 17, 2021

Howdy!

I've started seeing an issue after updating a project to use 2.1.0 and correspondingly Sleuth 3.0.x.

If you have an application with an auto-configuration class which has a dependency on Tracer (from Sleuth), then a noop Sampler is auto-configured, and no traces are sampled without manually configuring a Sampler.

I have a small project which demonstrates the issue here. The application adds a simple auto-configuration class as follows:

@Configuration
@ConditionalOnBean(Tracer.class)
@AutoConfigureAfter(BraveAutoConfiguration.class)
public class CustomAutoConfigUsingTracer {
	@Bean
	public String dependency(Tracer tracer) {
		return "test";
	}
}

When the application runs, the AutoConfigureAfter forces this component to be registered after Brave and correspondingly BraveSamplerConfiguration. Unfortunately, that seems to ignore the AutoConfigureBefore requirement that WavefrontTracingSleuthConfiguration should run before BraveAutoConfiguration. This causes issues because Sleuth has a SamplerCondition which configures a real Sampler if a custom TracingCustomizer has been configured (which WavefrontTracingSleuthConfiguration adds).

If you run the demo project, you would see this output indicating the order in which the auto-configuration classes are loaded, and correspondingly, the sampler that was configured:

  3 - org.springframework.cloud.sleuth.autoconfig.brave.BraveAutoConfiguration
  4 - com.wavefront.autoconfigissue.AutoConfigIssueDemo.CustomAutoConfigUsingTracer
  5 - org.springframework.boot.actuate.autoconfigure.metrics.MetricsAutoConfiguration
  6 - org.springframework.boot.actuate.autoconfigure.metrics.export.wavefront.WavefrontMetricsExportAutoConfiguration
  7 - com.wavefront.spring.autoconfigure.WavefrontAutoConfiguration
  ...
  Sampler is: NeverSample

Prior to 2.1.0 (and Sleuth 3.0.x) this same code worked as expected and a real Sampler is auto-configured by Sleuth/Brave. I believe this was possibly introduced by #92 here.

It's very unclear to me which component is at fault here, or where this issue could be addressed most effectively. The example project and corresponding auto-configuration are very similar to how a library I've been using instruments database queries via p6spy, which is how I ran into this issue.

Would greatly appreciate any input/feedback. I'm really unsure how to address this without a custom Sampler configuration, which isn't great experience given that the Sampler auto-configuration used to work.

Thanks!!!

@thepeterstone thepeterstone self-assigned this May 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants