Closed
Listed in
Description
This issue was originally reported here: #34508 (comment) by @chicobento:
Hi @jonatan-ivanov , we are facing some issues integrating this into our project. The scenario is the following:
- we have a custom class that implements
SpanExporter
interface and internally wraps our own mutableOtlpHttpSpanExporter
- with this, we need to prevent the
OtlpAutoConfiguration
from creating theOtlpHttpSpanExporter
Bean. However, the @ConditionalOnMissingBean is based only on OtlpHttpSpanExporter and OtlpGrpcSpanExporter beans, which is not our case as we implementSpanExporter
interface and cannnot descend from theOtlpHttpSpanExporter
since its finalSome possible solutions to my problem that I tried:
- Remove
OtlpAutoConfiguration
: this behavior is added by a internal library, so I cannot easily remove theOtlpAutoConfiguration
without impacting the applications that uses our lib- Replace the
SpanProcessor
: as theOpenTelemetryAutoConfiguration.otelSpanProcessor
method does not have a@ConditionalOnMissingBean
. I cannot easily replace theSpanProcessor
with a custom one that would ignore theOtlpHttpSpanExporter
Bean provided byOtlpAutoConfiguration
- Replace the
OpenTelemetryAutoConfiguration.otelSdkTracerProvider
: this would not work because theSpanProcessor.otelSpanProcessor
will always instantiate a BatchSpanProcessor and start its thread. I'd have to shutdown itDo you have any other suggestion on how can I overcome this ?
I was wondering if isn't the current
OtlpAutoConfiguration.otlpHttpSpanExporter
factory method too intrusive as it always provide aSpanExporter
Bean even when the application has already defined its ownSpanExporter
? Can we change this to a simple@ConditionalOnMissingBean(SpanExporter.class)
?
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
jonatan-ivanov commentedon May 23, 2023
Some of the behaviors you described here are intentional: we wanted to allow additional
SpanExporter
andSpanProcessor
beans to be defined while keeping the default beans that we provide. E.g.: since you haveOtlpHttpSpanExporter
on the classpath we assumed you want to use it as an exporter but we also let you to create another, custom one.SpanProcessor
is similar, see this issue: #35560 and this comment: #35558 (comment)This is also why we cannot really do this:
@ConditionalOnMissingBean(SpanExporter.class)
that would mean that the second bean is not an addition but an override.I do have a couple of ideas:
enabled
flag forOtlpAutoConfiguration
. This is a bit problematic since we already have a signal to enable/disable it, it is the presence of theOtlpHttpSpanExporter
class but if we have a valid use-case, we can reconsider this and add the flag.SpanProcessor
@Primary
and shut down the second one in a bean post processor.OtlpHttpSpanExporter
but it was intentionally madefinal
. What is the custom behavior you want to add toOtlpHttpSpanExporter
? Can this behavior added toOtlpHttpSpanExporter
itself? Or can you open an issue to makeOtlpHttpSpanExporter
non-final?mhalbritter commentedon May 23, 2023
One thing we could think about if we should introduce an abstraction which can veto that a
SpanProcessor
is added to theSdkTracerProvider
. Something like:That would solve the problem with multiple
SpanProcessor
s on a more abstract level.chicobento commentedon May 23, 2023
Hi @jonatan-ivanov ,
Thanks for the quick response.
Regarding option 3, the main reason why we override the
OtlpHttpSpanExporter
bean is that we need support for custom TLS certificates and certificate refresh scenario.So, in our solution we created a
MutableSpanProcessor
that encapsulates aOtlpHttpSpanExporter
and refreshes the inner instance whenever new certificates are issued. Open telemetry already helped by improving their support for custom certificates (such as item open-telemetry/opentelemetry-java#5211), and I dont think extending theOtlpHttpSpanExporter
would be of much help.Now regarding option 2 (and @mhalbritter proposal variant), the drawback is that the
BatchSpanProcessor
threads are created/started and then shutdown - which is not nice.So I think that we are left only with option 1 because of the BWC concerns with the additivity behavior of the SpanProcessors.
jonatan-ivanov commentedon May 23, 2023
I think to me being able to extend
OtlpHttpSpanExporter
would make sense, why do you think it would not be helpful? (I'm not eure OTel will do this though.)I think option 2 is more like a workaround till this is not fixed because of the need to shutting down the processor.
@mhalbritter What do you think about introducing enable flags (maybe for zipkin too)?
mhalbritter commentedon May 24, 2023
I'm not a big fan of those enabled flags, but if we don't find a better solution, maybe that's the pill we have to swallow. Maybe someone else from the team has a better idea, let's talk about that in our next meeting.
chicobento commentedon May 24, 2023
I agree, it'd be useful, it is just hard to find a concrete use-case to justify this and dont have big expectations since OTel is very strict with their API surface.
philwebb commentedon May 24, 2023
We discussed this today and one idea we're considering is to remove the default
OtlpProperties.endpoint
value. This would mean that if users want HTTP export they'd need to addmanagement.otlp.tracing.endpoint=http://localhost:4318/v1/traces
to their properties.This would give us a strong signal about when we'd auto-configure an
OtlpHttpSpanExporter
.There are a couple of downsides to this approach. 1) It's a breaking change. 2) It makes configuration a little more verbose.
philwebb commentedon May 24, 2023
In the meantime you could try adding
spring.autoconfigure.exclude=org.springframework.boot.actuate.autoconfigure.tracing.otlp.OtlpAutoConfiguration
to yourapplication.properties
or using@SpringBootApplication(exclude=OtlpAutoConfiguration.class)
to disable our auto-configuration.chicobento commentedon May 24, 2023
Hi @philwebb, fair enough.
You mean that you'll add a
@ConditionalOnProperty(management.otlp.tracing.endpoint)
? Since it is a breaking change anyways, why not also adding@ConditionalOnMissingBean(SpanExporter.class)
?Yeap, I was trying to avoid that because we provide our custom
SpanExporter
bean in a shared library jar, so I'd like to avoid impacts on the applications, but at this point this seems to be one of the best options (or either shutting down the processor).Thanks a lot everyone for the quick response.
chicobento commentedon May 24, 2023
BTW, for our specific deployment, the OTLP Collector is running remotely, so even if we could stick to the stock
OtlpHttpSpanExporter
, we'd have to configure the endpoint anyways.23 remaining items