Agent Auto Configuration can overwrite an extension's customer Sampler #315
Labels
status: oncall
Flagged for awareness from Honeycomb Telemetry Oncall
type: bug
Something isn't working
Headline
The way HoneycombAutoConfigurationCustomizerProvider is written, (calling
SdkTracerProviderBuilder.setSampler()
), it can overwrite aSampler
installed by an OTel Java Agent extension that is intended to decorate whatever other sampling is in place.Versions
Steps to reproduce
Sampler
, decorating the already installed one. (This is not a trivial task. You can see some of the steps I've taken to do this here. But the bug is pretty obvious from the code.)Expected Behaviour
HoneycombAutoConfigurationCustomizerProvider
should customize (i.e. decorate) anySampler
already in the configuration, so that the extension'sSampler
decorating behaviour is effective, irrespective of what orderAutoConfigurationCustomizerProvider
s are loaded.Actual Behaviour
Depending on the order in which Java's
ServiceLoader
loads the twoAutoConfigurationCustomizerProvider
s (Honeycomb's and the extension's), it's possible (and happens consistently, for me) that Honeycomb's code overwrites the extension's customSampler
.Additional context
The
HoneycombAutoConfigurationCustomizerProvider
overwrites whatever sampler is in the configuration already:honeycomb-opentelemetry-java/custom/src/main/java/io/honeycomb/opentelemetry/HoneycombAutoConfigurationCustomizerProvider.java
Lines 31 to 33 in fd6a2a2
I can't see any way to control the order in which
AutoConfigurationCustomizerProvider
s are executed, either in theServiceLoader
feature or in the design/usage ofAutoConfigurationCustomizerProvider
(in OTel'sAutoConfiguredOpenTelemetrySdkBuilder.build()
).Honeycomb's auto config should probably, instead of setting the
Sampler
, decorate whateverSampler
is already installed, using theaddSamplerCustomizer()
extension point, as shown here:open-telemetry/opentelemetry-java-instrumentation#5008 (comment)
The text was updated successfully, but these errors were encountered: