Introduce ConfigProvider API#6549
Conversation
|
From what I understand, if you provide an implementation for StructuredConfigProperties, then the getConfig(): Will return your implementation, If you provide no implementation, then the existing propertiesSupplier and propertiesCustomizerswill kick in.Right? |
No. This API only provides |
Sorry, I'm confused. private ConfigProperties getConfig() {
ConfigProperties config = this.config;
if (config == null) {
config = computeConfigProperties();
}
return config;
}If no structured properties are present, properties will be computed from current |
Sorry I must have misunderstood your question. This PR introduces net new (experimental) API surface area in the |
|
thanks |
codefromthecrypt
left a comment
There was a problem hiding this comment.
handy. hope the review helps despite being not authoritative @jack-berg!
api/incubator/src/main/java/io/opentelemetry/api/incubator/config/ConfigProvider.java
Outdated
Show resolved
Hide resolved
api/incubator/src/main/java/io/opentelemetry/api/incubator/config/ConfigProvider.java
Show resolved
Hide resolved
api/incubator/src/main/java/io/opentelemetry/api/incubator/config/GlobalConfigProvider.java
Show resolved
Hide resolved
api/incubator/src/main/java/io/opentelemetry/api/incubator/config/GlobalConfigProvider.java
Show resolved
Hide resolved
...incubator/src/main/java/io/opentelemetry/api/incubator/config/InstrumentationConfigUtil.java
Outdated
Show resolved
Hide resolved
| assertThat(InstrumentationConfigUtil.peerServiceMapping(emptyHttpConfigProvider)).isNull(); | ||
| } | ||
|
|
||
| @Test |
There was a problem hiding this comment.
recommend tests for below cases possibly something that can be refactored to a common fixture for all, but even if explicit 1. path is incomplete 2. middle of the path is the wrong type 3. end of the path is the wrong type 4. end of the path is empty
.../src/main/java/io/opentelemetry/sdk/autoconfigure/AutoConfiguredOpenTelemetrySdkBuilder.java
Outdated
Show resolved
Hide resolved
| StructuredConfigProperties otherMapKeyProps = otherProps.getStructured("map_key"); | ||
| assertThat(otherMapKeyProps).isNotNull(); | ||
| assertThat(otherMapKeyProps.getString("str_key1")).isEqualTo("str_value1"); | ||
| ConfigProvider globalConfigProvider = GlobalConfigProvider.get(); |
There was a problem hiding this comment.
if we care, we run this again to test that the value returned is a constant
...or/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/FileConfigProvider.java
Outdated
Show resolved
Hide resolved
…y-java into config-provider
Thanks for your time - lots of good advice in here 🙂 |
Codecov ReportAttention: Patch coverage is
❌ Your patch status has failed because the patch coverage (77.22%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #6549 +/- ##
============================================
+ Coverage 89.85% 89.91% +0.05%
- Complexity 6615 6663 +48
============================================
Files 740 748 +8
Lines 19991 20093 +102
Branches 1964 1977 +13
============================================
+ Hits 17963 18066 +103
+ Misses 1439 1434 -5
- Partials 589 593 +4 ☔ View full report in Codecov by Sentry. |
Resolves #3535. This introduces an API component to file configuration, which has been limited to SDK (i.e. end user facing) up until this point. The configuration model recently added the first surface area related to instrumentation configuration properties in open-telemetry/opentelemetry-configuration#91. The API proposed in this PR is collectively called the "Instrumentation config API", and provides a mechanism for instrumentation libraries to participate in file configuration and read relevant properties during initialization. The intent is for both OpenTelemetry-authored and native instrumentation alike to be able to be configured by users in a standard way. New API surface area is necessary to accomplish this to avoid instrumentation libraries from needing to take a dependency on SDK artifacts. The following summarizes the additions: - Introduce ConfigProvider, the instrumentation config API analog of TracerProvider, MeterProvider, LoggerProvider. This is the entry point to the API. - Define "Get instrumentation config" operation for ConfigProvider. This returns something called ConfigProperties, which is a programmatic representation of a YAML mapping node. The ConfigProperties returned by "Get instrumentation config" represents the [`.instrumentation`](https://github.com/open-telemetry/opentelemetry-configuration/blob/670901762dd5cce1eecee423b8660e69f71ef4be/examples/kitchen-sink.yaml#L438-L439) node defined in a config file. - Rebrand "file configuration" to "declarative configuration". This expresses the intent without coupling to the file representation, which although will be the most popular way to consume these features is just one possible way to represent the configuration model and use these tools. - Break out dedicated `api.md`, `data-model.md`, and `sdk.md` files for respective API, data model, and SDK portions of declarative configuration. This aligns with other portions of the spec. The separation should improve clarity regarding what should and should not be exposed in the API. I've prototyped this new API in `opentelemetry-java` here: open-telemetry/opentelemetry-java#6549 cc @open-telemetry/configuration-maintainers, @open-telemetry/specs-semconv-maintainers
|
The spec PR introducing the configuration API is merged and I'm now seeking reviews for this with the intent to merge. |
codefromthecrypt
left a comment
There was a problem hiding this comment.
@geoand @ThomasVitale I know both of you work in different frameworks, so that's a good thing ;) Imagine in LLM a setting for disabling prompt logging, and this would be obtained by a config provider, using config semantics that also apply to other languages like python or Go.
In understand that in your frameworks, config loading compat might not be a specific goal, but if you have any commentary around this impl, it would be much obliged. conventional and standardized loading is very helpful when agents are in use.
|
Thanks for the ping! I'll have a look next week when I'm back from PTO |
Resolves open-telemetry#3535. This introduces an API component to file configuration, which has been limited to SDK (i.e. end user facing) up until this point. The configuration model recently added the first surface area related to instrumentation configuration properties in open-telemetry/opentelemetry-configuration#91. The API proposed in this PR is collectively called the "Instrumentation config API", and provides a mechanism for instrumentation libraries to participate in file configuration and read relevant properties during initialization. The intent is for both OpenTelemetry-authored and native instrumentation alike to be able to be configured by users in a standard way. New API surface area is necessary to accomplish this to avoid instrumentation libraries from needing to take a dependency on SDK artifacts. The following summarizes the additions: - Introduce ConfigProvider, the instrumentation config API analog of TracerProvider, MeterProvider, LoggerProvider. This is the entry point to the API. - Define "Get instrumentation config" operation for ConfigProvider. This returns something called ConfigProperties, which is a programmatic representation of a YAML mapping node. The ConfigProperties returned by "Get instrumentation config" represents the [`.instrumentation`](https://github.com/open-telemetry/opentelemetry-configuration/blob/670901762dd5cce1eecee423b8660e69f71ef4be/examples/kitchen-sink.yaml#L438-L439) node defined in a config file. - Rebrand "file configuration" to "declarative configuration". This expresses the intent without coupling to the file representation, which although will be the most popular way to consume these features is just one possible way to represent the configuration model and use these tools. - Break out dedicated `api.md`, `data-model.md`, and `sdk.md` files for respective API, data model, and SDK portions of declarative configuration. This aligns with other portions of the spec. The separation should improve clarity regarding what should and should not be exposed in the API. I've prototyped this new API in `opentelemetry-java` here: open-telemetry/opentelemetry-java#6549 cc @open-telemetry/configuration-maintainers, @open-telemetry/specs-semconv-maintainers
zeitlinger
left a comment
There was a problem hiding this comment.
I think the API ergonomics could be improved - but nothing that I would insist on.
...incubator/src/main/java/io/opentelemetry/api/incubator/config/InstrumentationConfigUtil.java
Outdated
Show resolved
Hide resolved
|
Alright I've done another pass at this to make sure that stable artifacts only have compileOnly dependencies on experimental artifacts. @trask would appreciate it if you could take a look! |
This PR introduces a new category of API surface area called ConfigProvider, which is analog to TracerProvider, MeterProvider, LoggerProvider.
ConfigProvider (and its corresponding global accessor GlobalConfigProvider) provides a mechanism for instrumentation to read data from the new
.instrumentationportion of declarative configuration.Why does instrumentation need to participate in config?
To provide a good user experience, we should centralize all otel config a user might provide in a single place. Limiting declarative config to SDK configuration just kicks the problem of instrumentation config down the road when the problem domains are quite similar.
Why do we need config surface area in the API instead of just SDK?
Historically, we've limited configuration to the SDK and the related autoconfigure module. (Although long ago we debated whether certain classes from the
opentelemetry-extension-autoconfigure-spilike ConfigProperties should be in theopentelemetry-apiinstead). This pattern breaks down with instrumentation config because we want native instrumentation to read from declarative config without taking a dependency on any SDK artifacts.What's the user flow for interacting with ConfigProvider?
Let's use the otel java agent as an example. Supposing a user opts into declarartive configuration by setting
OTEL_EXPERIMENTAL_CONFIG_FILE=/path/to/config.yaml, the agent will install an SDK configured according to the file contents using logic inopentelemetry-sdk-extension-autoconfigure/opentelemetry-sdk-extension-incubator, which are bundled with the otel java agent.This PR extends the autoconfigure logic to initialize a ConfigProvider instance when
OTEL_EXPERIMENTAL_CONFIG_FILEis specified, which is accessible in via:AutoConfigureUtil#getConfigProvider()GlobalConfigProvider#get()ConfigProviderhas just a single operation right now:Where StructuredConfigProperties represents the YAML node at
.instrumentationfrom the user's config file. I've added convenience methods in InstrumentationConfigUtil to read common properties:And a convenience method for accessing properties specific to a particular instrumentation library:
The agent would need to be updated to detect that file configuration was used, and to configure the various instrumentation libraries it installs according to the installed ConfigProvider.
Any native instrumentation can similarly read ConfigProvider on initialization and configure itself accordingly.
What does this PR do to make all this work?
There are lot of files changed to accomplish this, but they mostly shift existing code around to move the required libraries to
opentelemetry-api-incubatormodule. Notably, the spec PR introducing the instrumentation configuration API rebrands "file configuration" to be "declarative configuration". Its best to do user facing class renames at the same time that those classes are moving packages to minimize churn.Here's a summary of the changes:
io.opentelemetry.api.incubator.configpackage inopentelemetry-api-incubatorto hold all classes / interfaces required for the config APIopentelemetry-sdk-extension-incubatortoopentelemetry-api-incubator, rename to DeclarativeConfigPropertiesopentelemetry-api-incubatorand can be referenced in API