-
Notifications
You must be signed in to change notification settings - Fork 839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce ConfigProvider API #6549
base: main
Are you sure you want to change the base?
Conversation
From what I understand, if you provide an implementation for StructuredConfigProperties, then the getConfig(): Line 429 in d9cef81
Will return your implementation, If you provide no implementation, then the existing propertiesSupplier and propertiesCustomizers will 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 🙂 |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
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
.instrumentation
portion 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-spi
like ConfigProperties should be in theopentelemetry-api
instead). 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_FILE
is specified, which is accessible in via:AutoConfigureUtil#getConfigProvider()
GlobalConfigProvider#get()
ConfigProvider
has just a single operation right now:Where StructuredConfigProperties represents the YAML node at
.instrumentation
from 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-incubator
module. 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.config
package inopentelemetry-api-incubator
to hold all classes / interfaces required for the config APIopentelemetry-sdk-extension-incubator
toopentelemetry-api-incubator
, rename to DeclarativeConfigPropertiesopentelemetry-api-incubator
and can be referenced in API