Skip to content

Prototype file config extensions#5873

Closed
jack-berg wants to merge 8 commits intoopen-telemetry:mainfrom
jack-berg:prototype-file-config-extensions
Closed

Prototype file config extensions#5873
jack-berg wants to merge 8 commits intoopen-telemetry:mainfrom
jack-berg:prototype-file-config-extensions

Conversation

@jack-berg
Copy link
Copy Markdown
Member

@jack-berg jack-berg commented Oct 2, 2023

@open-telemetry/java-instrumentation-maintainers in the 9/21 Java SIG meeting I brought up bringing the file configuration prototype into the java agent, and received feedback that it will be important to specify other java agent properties besides the SDK in a configuration. Examples include accessing jmx configuration, and other standard properties like otel.javaagent.debug=true.

Please check out this proposal for extending file configuration tooling to include and access configuration not part of the configuration schema. Summary:

  • A user specifies both SDK and java agent configuration in a single YAML file, and sets OTEL_CONFIG_FILE to the file path
  • Autoconfigure detects that OTEL_CONFIG_FILE is set and that opentelemetry-sdk-extension-incubator is on the classpath, and:
    • Parses / interprets the config file to configure the SDK
    • Converts the OpenTelemetryConfiguration model to a generic ExtendedConfigProperties representation accessible via AutoConfiguredOpenTelemetrySdk#getConfig()
  • ExtendedConfigProperties implements ConfigProperties and adds some additional methods for accessing nested complex configuration types (nested maps, and lists of maps)
  • The opentelemetry java agent accesses ExtendedConfigProperties and uses it for configuration

Suppose you have a configuration file with contents like:

file_format: "0.1"
tracer_provder:
  processors:
    - batch:
        exporters:
          otlp:
javaagent:
  debug: true
  jmx:
    foo: bar

In java, you use the file to configure the SDK, as well as access the extended "javaagent" portion of the schema as follows:

export OTEL_CONFIG_FILE=/path-to-config.yaml
...
AutoConfiguredOpenTelemetrySdk autoConfiguredSdk = AutoConfiguredOpenTelemetry.builder().build();
ExtendedConfigProperties configProps = (ExtendedConfigProperties) autoConfiguredSdk.getConfig();

ExtendedConfigProperties javaagentProps = configProps.getConfigProperties("javaagent");
Boolean debug = javaagentProps.getBoolean("debug");
ExtendedConfigProperties jmxProps = javaagentProps.getConfigProperties("jmx");
String foo = jmxProps.getString("foo");

assert foo.equals("bar");

// Or use dot notation 
assert configProps.get("javaagent.jmx.foo").equals("bar");
assert configProps.get("javaagent.debug").equals(true);

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 2, 2023

Codecov Report

Attention: 25 lines in your changes are missing coverage. Please review.

Files Coverage Δ
...ion/incubator/fileconfig/ConfigurationFactory.java 84.37% <100.00%> (+8.18%) ⬆️
...nfigure/AutoConfiguredOpenTelemetrySdkBuilder.java 94.44% <88.63%> (+2.51%) ⬆️
...incubator/fileconfig/ExtendedConfigProperties.java 81.81% <81.81%> (ø)

📢 Thoughts on this report? Let us know!.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant