Make snakeyaml-engine and jackson-databind optional at runtime#8270
Open
zeitlinger wants to merge 10 commits intoopen-telemetry:mainfrom
Open
Make snakeyaml-engine and jackson-databind optional at runtime#8270zeitlinger wants to merge 10 commits intoopen-telemetry:mainfrom
zeitlinger wants to merge 10 commits intoopen-telemetry:mainfrom
Conversation
Split DeclarativeConfiguration into two classes: - DeclarativeConfiguration: create(model) only, no YAML/jackson-databind deps - DeclarativeConfigurationParser: all parsing (MAPPER static block, parse, loadYaml, parseAndCreate, toConfigProperties, createSampler, env-var substitution, snakeyaml inner classes) Change snakeyaml-engine and jackson-databind from implementation to compileOnly in build.gradle.kts (keeping jackson-annotations as api since the generated model POJOs use @JsonProperty etc. as public API). Remove the unused jackson-dataformat-yaml dependency. Users who only call DeclarativeConfiguration.create(model) for programmatic SDK configuration no longer incur transitive YAML/jackson-databind deps. Users who need YAML parsing add snakeyaml-engine and jackson-databind and call DeclarativeConfigurationParser.parseAndCreate(stream). This also opens the door for merging declarative config into autoconfigure, since the static initializer that caused NoClassDefFoundError when jackson-databind was absent is now isolated in DeclarativeConfigurationParser. Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
…rser Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
…module - All fileconfig source files moved from sdk-extensions/incubator to sdk-extensions/autoconfigure, removing the hard dependency on incubator for users who only need autoconfigure - New testDeclarativeConfig test suite in autoconfigure with isolated classpath so existing autoconfigure tests (which check for absent exporters) are not polluted - Updated INCUBATOR_AVAILABLE check to look for api:incubator (DeclarativeConfigException), and added separate PARSER_AVAILABLE check for snakeyaml - New sdk-extensions/autoconfigure-config convenience module that bundles autoconfigure + snakeyaml + jackson-databind for users who want file-based config out of the box - YAML test resources added to incubator/src/test/resources (ViewConfig tests still need them) Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
…toconfigure module Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
- Delete fileconfig tests from src/test/ (they were moved to testDeclarativeConfig
in the previous commit but deletions were not staged)
- Fix ViewConfig/ViewConfigCustomizer javadoc: replace broken {@link} cross-module
reference to DeclarativeConfigurationParser with {@code} (class moved to
autoconfigure module which is not a main-scope dep of incubator)
- Delete incubator META-INF/services ComponentProvider registration (ServiceResourceDetector
moved to autoconfigure module)
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
…o testConvertToModel - NoSharedInternalCodeTest: skip check when jar has no OpenTelemetry classes; autoconfigure-config is a dependency-only convenience module with no Java sources - api/incubator testConvertToModel: add snakeyaml-engine to runtime deps; DeclarativeConfigurationParser (now in autoconfigure) uses snakeyaml internally but autoconfigure declares it compileOnly so it doesn't flow transitively Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8270 +/- ##
============================================
- Coverage 90.29% 90.29% -0.01%
- Complexity 7656 7657 +1
============================================
Files 844 845 +1
Lines 23071 23081 +10
Branches 2311 2311
============================================
+ Hits 20832 20841 +9
Misses 1521 1521
- Partials 718 719 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…urce package-private Both were public but only used within the autoconfigure module. ResourceFactory (different package, same module) now uses ResourceConfiguration.createEnvironmentResource and inlines the property name string instead. Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR does two things:
1. Split YAML parsing out of
DeclarativeConfigurationDeclarativeConfigurationis split into two classes to make YAML dependencies optional at runtime:DeclarativeConfiguration—create(model)methods only. No dependency onsnakeyaml-engineorjackson-databindat runtime.DeclarativeConfigurationParser— all YAML parsing:MAPPERstatic block,parse(),loadYaml(),parseAndCreate(),toConfigProperties(), env-var substitution.The
MAPPERfield in the original class is astatic finalwith a static initializer. Loading the class to callcreate(model)triggered that static block, failing withNoClassDefFoundErrorifjackson-databindwas absent. Moving the static block toDeclarativeConfigurationParserbreaks the link — the JVM only loads it when parser methods are actually called.2. Move all declarative config (fileconfig) from
incubatorintoautoconfigureAll ~45
fileconfigsource files are moved fromsdk-extensions/incubatortosdk-extensions/autoconfigure. This is the direction suggested in #8265 — the YAML dep concern is resolved by the class split above.A new
sdk-extensions/autoconfigure-configconvenience module bundlesautoconfigure+snakeyaml-engine+jackson-databindfor users who want everything in one dependency (Spring Boot starter style).Dependency graph
graph TD config["autoconfigure-config\n(convenience bundle)"] autoconfigure["autoconfigure\n(fileconfig included)"] incubator["incubator\n(ViewConfig, SPI extensions)"] api-incubator["api:incubator"] snakeyaml["snakeyaml-engine"] jackson["jackson-databind"] jackson-ann["jackson-annotations"] config -->|api| autoconfigure config -->|runtimeOnly| snakeyaml config -->|runtimeOnly| jackson autoconfigure -->|api| jackson-ann autoconfigure -.->|"compileOnly (YAML parsing)"| snakeyaml autoconfigure -.->|"compileOnly (YAML parsing)"| jackson autoconfigure -.->|"compileOnly (fileconfig)"| api-incubator autoconfigure -.->|"compileOnly (optional SPI)"| incubator incubator -->|api| api-incubatorDashed arrows =
compileOnly/ optional at runtime. YAML file config requires snakeyaml + jackson + api:incubator at runtime;autoconfigure-configprovides all three.What changes for users
AutoConfiguredOpenTelemetrySdk(env/props only)autoconfigureautoconfigure(unchanged)otel.config.file)autoconfigure+incubator+ snakeyaml + jacksonautoconfigure-configDeclarativeConfiguration.create(model)incubator+ snakeyaml + jackson (YAML deps leaked)autoconfigureonlyautoconfigure+incubator+ api:incubatorRelated to / supersedes the direction in #8265.