open-telemetry / opentelemetry-java

OpenTelemetry Java SDK
https://opentelemetry.io
Apache License 2.0
1.93k stars 791 forks source link

ConfigurationFileLoader for OpenTelemetry manual instrumentation #5428

Open tusharg1993 opened 1 year ago

tusharg1993 commented 1 year ago

Is your feature request related to a problem? Please describe. We are using OpenTelemetry javaagent for auto instrumentation and library for manual instrumentation. We are currently using otel.javaagent.configuration-file for java agent and load different configuration files for dev/prod environments and we pass the same using the environment variable.

We found that AutoConfiguredOpenTelemetrySdk also uses the same set of properties however, doesn't support loading configuration file like javaagent. I am wondering if there was ever a thought for enabling similar mechanism for manual instrumentation via autoconfiguration to accept a file as well. This way, we can reuse the same config file for both auto and manual instrumentation.

Describe the solution you'd like Overall, idea was to implement something similar to ConfigurationFileLoader with a config like otel.autoconfiguration.configuration-file which gets used in AutoConfiguredOpenTelemetrySdkBuilder.getConfigs. We might want to have a different config values for java agent vs auto configured open telemetry objects since some usecases might want to have different customizations between auto vs manual instrumentation.

Describe alternatives you've considered Nothing else really. Only thing I could probably do is add similar kind of code in my service to read a file and then pass AutoConfiguredOpenTelemetrySdkBuilder.propertiesSupplier()

Additional context Covered above

trask commented 1 year ago

I think this probably belongs in https://github.com/open-telemetry/opentelemetry-java, I will transfer it

I suspect this may be on hold until https://github.com/open-telemetry/opentelemetry-specification/issues/2920

jack-berg commented 1 year ago

We're currently working on a file based configuration as described in this otep. Its a work in progress, but it will eventually include all the current environment configuration parameters and more options that we've been reluctant to define with flat environment variables.

tusharg1993 commented 1 year ago

Thanks for the pointers @trask @jack-berg!

@jack-berg If I am understanding the links correctly, the idea is precisely to allow hierarchical file based configurations for OpenTelemetry java SDK. Please confirm.

Also, are you looking to release this functionality in short term? We will be willing to give it a try. :)

jack-berg commented 1 year ago

@jack-berg If I am understanding the links correctly, the idea is precisely to allow hierarchical file based configurations for OpenTelemetry java SDK. Please confirm.

I say highly structured configuration that better reflects the configurable surface area of the SDK than the current environment variable scheme.

Also, are you looking to release this functionality in short term?

Short-ish term. I've got a branch / PR where I've started the java implementation work in #5399. I think the limited factor will be agreeing on the actual configuration schema in opentelemetry-configuration. We're tracking the scope for MVP release here, so good to follow that project if you're interested.

Nothing else really. Only thing I could probably do is add similar kind of code in my service to read a file and then pass AutoConfiguredOpenTelemetrySdkBuilder.propertiesSupplier()

You could do this automatically (i.e. not have to invoke any code) by implementing the AutoConfigurationCustomizerProvider SPI and calling AutoCOnfigurationCustomizer#addPropertiesSupplier. Not a bad option if you need this now and are in a pinch.