-
Notifications
You must be signed in to change notification settings - Fork 840
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
Java implementation of the File Configuration #6170
Comments
I'm not sure about the config collisions part because it seems to me that if we don't allow env. var. configs to particular configurations, it seems to me it will be dificult to find unique keys to identify all the property names in the |
Incorrect. The programmatic interface are the builders for the specific components: BatchSpanProcessor, OtlpGrpcSpanExporter, Resource, PeriodicMetricReader, etc. The autoconfigure module is an abstraction which interprets the environment variable configuration scheme and configures the SDK using the programmatic configuration interfaces of individual components.
You're using normative language here, but its not taken from the specification. I assume you're expressing a strong opinion then?
I'm not sure what you're trying to convey here. The example you include is taken out of context. I wrote that example because Diego and I were talking about how some SDK implementations directly embed interpretation of environment variables into the components (in contrast to opentelemtry-java which extracts that to the separate autoconfigure artifact). We were discussing that example wondering how those other SDK implementations handle the types of environment variable conflicts today.
What spec language are you referencing here?
Whether or not file configuration supports environment variable overrides (still not decided and being actively debated), there would be nothing forcing a user or a framework to use file configuration, or the environment variable scheme for that matter. A user or framework will always be able to simply not use the autoconfigure module and use their own configuration scheme with the low level programmatic APIs. |
We should clarify this, because that is not my understanding. The properties supplier is generic enough and not dependent of any "environment variable" in order to work, if entries come from env. vars. or any other place, the map doesn't care.
This part is a proposal. Open for debate.
Here: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-configuration.md We definitely need to clarify and define somewhere what is considered the programatic interface in the case of Java.
True, if frameworks weren't using already the Autoconfiguration to create an SDK. This effectively means a breaking change for existing systems and a message to not use the Autoconfiguration. |
Can you please clarify what problem this issue is trying to solve? I read the entire issue and couldn't figure out the pain points the issue is trying to solve. From my understanding, the programmatic interface is the *Builder classes, allowing you to build
I read the SDK specification you linked, and it answers that precisely. |
@asafm these are some of the points to clarify:
I don't question the merits of the tech solution proposed by @jack-berg. His work is an example to all of us. |
CC @kittylyst |
I think they were trying as much as possible not to be overly specific in the spec, as it can create havoc later. Okay, let's work through your answers to the questions to get to the bottom of the problems you see. |
Quarkus, Wildfly, OpenLiberty, Payara, Spring, etc...
These are the Autoconfigure properties: https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md#general-configuration
Changed on the PR mentioned in the description. The code in here
I disagree because of the complexity of setting up an SDK. Have you try to do it without the Autoconfigure for a real world app (Multithreaded+REST+DB+heath+Security+Resources+Dependency Injection+etc) ?
You have the same property with different values in the file and on an env. var. Who wins?
|
No its not generic enough. There are many things that cannot be expressed using flat properties. For example, non-trivial processor configurations, views, and non-trivial sampler configurations. The customization options in autoconfiguration are largely in direct response to inadequate expressive power of the flat scheme we have today.
I think that's a decision frameworks will have to make:
This decision should be analogous to how frameworks handle log configuration files today:
Why shouldn't the story with opentelemetry be the same?
This is not ambiguous. The module description is:
The first line of the autoconfigure readme (present since > 3 years ago) states:
Incorrect. There is no behavior change when the input (i.e. environment variables and system properties and SPIs) is the same. The conditions to trigger a change are explicitly setting This genie can't be put back in the bottle. The OpenTelemetry community is committed to having a file format. The TC put a moratorium on enhancements to the env variable scheme, a dedicated working group was spun up, an OTEP was long debated and approved, a bunch of work has been debated and merged to the spec regarding file configuration, and there are prototypes in at least 3 languages. The wheels are in motion - the opentelemetry community will not be limited to a flat env var / system property style configuration scheme. There are open questions about how file configuration interacts with the environment variable config scheme, and for java specifically, its appropriate to debate how file configuration should interact with autoconfigure tooling. But file configuration is happening, and over time its likely to supplant the environment variable scheme as the dominant configuration mechanism. |
Thanks @jack-berg this makes much more sense now.
Are you aware of any java framework that starts the SDK without the Autoconfiguration? Is this really a practical choice or even something that we want to incentivise?
The files can be used but also other methods. In Quarkus those files are not needed.
But it doesn't mention file config, does it?... This was not under the radar when the Autoconfiguration was created, I acknowledge. Let me suggest a design alternative to highlight my pain points. We could rearrange things in a way that allows existing use but also provides a path forward to existing Autoconfiguration users to use the new, richer model. You can argue that current configurations will not map perfectly to the new model, but does this mapping have to be perfect? Maybe this transformation can happen painlessly on 90% plus of the cases, no? |
I haven't been following all the details here, but one thing that is non-negotiable... everything must be configurable, by an end-user writing code using public APIs. We cannot have "hidden", non-public methods for configuring the SDK that are only accessible via file or env-var configuration. |
Spring, and specifically the opentelemetry spring boot starter. I don't have a list of all the frameworks that integrate with OpenTelemetry and how they do configuration.
The same is true here.
It doesn't need to. All of file configuration can be implemented as an AutoConfigurationCustomizerProvider. Nothing needs to be built into the autoconfigure module for file configuration to completely override the autoconfiguration output. I just need to implement a customizer with a high order number, and replace the
Can you elaborate? I can't tell what you mean by this. |
Also see this document explaining some of the original thinking behind SDK configuration design: https://github.com/open-telemetry/opentelemetry-java/blob/main/docs/sdk-configuration.md#goals-and-non-goals Note that all the emphasis is on the builders as the configuration mechanism. Note that listed as a "non-goal" is:
|
If the rich file model allows configurations that are not possible with env vars, would this mean some of the configurations could only be performed using the file? |
This is a loaded question. Whether or not all components of a configuration file are representable with env vars is currently being debated. As discussed in this comment, if we merge the existing environment variable scheme its unlikely everything in file configuration will be representable. But if we ignore the existing environment variable scheme and invest a new one with names that are derived from the configuration model, then its likely that everything in file configuration will be representable with environment variables. If this is important to you then I suggest you go advocate for that. But I want to emphasize that the file configuration mechanism comes paired with a configuration model, which is produced as a result of parsing a configuration file, but which can also be programmatically constructed or edited. |
This sounds good to me in principle, but the current discussion seems to be file centric and requiring a file to work. At least in the Autoconfigure it currently requires a file to work. Could we get a method were we send not a file but a configuration object to create the SDK in the same fashion the file does? |
Is this what you are looking for, or something slightly different?
|
I need to see the details, but that could work. |
See the file configuration spec requirement for a configuration model, and for a method called create which accepts a configuration model and returns configured SDK components. The java embodiment of the model is a (currently generated) class called The idea behind an SPI would be something like:
Giving implementations full ability to customize the configuration model before it is used to configure the SDK. |
This issue pretends to be an umbrella to steer the implementation of the File Configuration under the Java SDK and related projects.
The file configuration of the SDK has been added to the project in this PR: #5831
This work must follow the guidelines established under the OpenTelemetry specification for the configuration of the SDK defined here: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-configuration.md
On the spec, it's mentioned that:
The programatic interface
The programatic interface in the Java SDK is the properties supplier defined in the
AutoConfigureOpenTelemetrySdkBuilder
asMap<String, String>> propertiesSupplier
The file configuration MUST provide a map of properties to this supplier and MUST NOT override the existing auto-configuration interfaces, namely, if a configuration file is provided, it MUST NOT take precedence over the provided programatic configurations, oTelConfigs, in this example:
Including existing signal builders, providers and customisers.
Config sources
Multiple configuration sources are defined in the spec without a sense of priorities, however, in Java it's common practice to have a hierarchy of configuration sources:
We can see that it's common practice for configurations to be sourced in many different ways and usually the same property can be set in many different sources.
Major java frameworks and cloud based systems in java assume precedence of env. vars. and sys. vars. over other configuration methods. This is a common, accepted and even expected practice.
Configuration collisions and unavailability.
If a source is not able to provide an unambiguous value for a particular configuration value, that configuration will be unavailable in that source. This behaviour must be documented and a default value must be provided. Example:
In this case it is not possible to use the env vars to configure 2 different exporters and they will end up with the same address. This must be documented. In the future, if required, support for this could be added by implementing new env. vars.
It should be noted however that frameworks integrating OpenTelemetry could find a solution of their own for this problem.
Configuration source independence
According to the OTel spec, A configuration must not be exclusive of a particular configuration source, namely the file configuration.
Broad support
By principle, libraries are much better off not forcing a specific way of configuration on users, but let those decisions be driven by frameworks - this makes library usage a breeze in the frameworks that integrate with said libraries, but also allows power users to provide arbitrary configuration options if desired.
Providing a file configuration alternative to "Java main()" standalone applications or the Java agent shouldn't interfere with other types of systems.
Maybe some aspects of the file configuration should be part of the Java agent and not the SDK itself.
There are related discussions on this PR: #5912
And these issues:
The text was updated successfully, but these errors were encountered: