Skip to content

Introduce DeclarativeConfigResult to eliminate reflection in IncubatingUtil#24

Merged
jack-berg merged 1 commit intojack-berg:break-incubator-autoconfigure-dependencyfrom
zeitlinger:declarative-config-result
Apr 7, 2026
Merged

Introduce DeclarativeConfigResult to eliminate reflection in IncubatingUtil#24
jack-berg merged 1 commit intojack-berg:break-incubator-autoconfigure-dependencyfrom
zeitlinger:declarative-config-result

Conversation

@zeitlinger
Copy link
Copy Markdown

Context

Builds on top of open-telemetry#8242.

The sharedState field reflection in IncubatingUtil introduced in open-telemetry#8242 is a regression — it accesses a private internal field of SdkMeterProvider to extract Resource, which is fragile and goes against the direction discussed in open-telemetry#7292.

Change

Introduce DeclarativeConfigResult (in fileconfig.internal — not public API) as the return type of DeclarativeConfiguration.create(). It carries both the configured SDK and Resource as first-class values, so IncubatingUtil can read them directly with no reflection.

Target module structure per open-telemetry#7292:

common (ComponentLoader)
  └── autoconfigure-spi (ConfigProperties, Ordered, ComponentProvider, AutoConfigureListener)
        └── sdk-config (OpenTelemetryConfigurationModel, SdkConfigProvider,
        |               DeclarativeConfiguration.create(), DeclarativeConfigContext,
        |               DeclarativeConfigurationProvider SPI,
        |               DeclarativeConfigurationCustomizer SPI)
              ├── sdk (OpenTelemetrySdk)
              ├── sdk-config-parse (DeclarativeConfiguration.parse(), Jackson/YAML)
              └── autoconfigure (invokes parse+create when OTEL_EXPERIMENTAL_CONFIG_FILE set)

DeclarativeConfigResult is the natural precursor to the result type that create() will need in the target architecture (where sdk-config cannot depend on sdk and must return individual providers + resource rather than an assembled OpenTelemetrySdk).

Does this match the target picture in open-telemetry#7292?

…ngUtil

Replace SdkMeterProvider.sharedState field reflection with a
DeclarativeConfigResult internal DTO that carries both the SDK and
Resource as first-class return values from DeclarativeConfiguration.create().

DeclarativeConfigResult lives in the fileconfig.internal package to
signal it is not public API, avoiding any increase in API surface while
still being accessible to autoconfigure via compileOnly dependency.
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger zeitlinger marked this pull request as ready for review April 7, 2026 13:33
@jack-berg jack-berg merged commit 4e4e405 into jack-berg:break-incubator-autoconfigure-dependency Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants