Skip to content

Re-use entire SDK auto-config in spring starter #10409

@zeitlinger

Description

@zeitlinger

#10292 is re-using the OTLP exporter logic from SDK auto-config.

There are still parts of the SDK auto-config that are not re-used currently, such as sampler

Technically, we could call the auto-config as a black box - and it would respect the spring properties.

What are the problems with this approach?

  • Users cannot supply beans programmatically, because the entire object graph is created in auto-config. Example: SdkLoggerProvider
  • SpiHelper uses META-INF loading (example) - wheres in Spring, users expect that @Beans are collected - we should probably load both to meet the expectations of Spring users and library authors alike.

Use Case 1: User supplies tracer provider

As a spring boot user, I want to provide my own instance of SdkTracerProvider (but let the framework configure the rest).

I'll configure the SdkTracerProvider programatically, using SdkTracerProvider.builder()....

Right now, this use case is supported with @ConditionalOnMissingBean, which instructs spring to prefer a user supplied object if available:

full code

    @Bean    
    @ConditionalOnMissingBean
    public SdkTracerProvider sdkTracerProvider(..) { .. }

The above code copies this part of the SDK auto-config code - just to add this annotation.

What can we do?

We can make the SpiHelper flexible enough that it allows

  • to pass in a discovery strategy
  • to pass a callback interface that checks for user supplied objects - user supplied beans in the case of spring
  • maybe also a callback to register the created objects in the spring bean context (not sure if there's a use case for that)

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions