Skip to content

Add env var substitution support to file configuration#5914

Merged
jack-berg merged 2 commits into
open-telemetry:mainfrom
jack-berg:file-config-env-vars
Oct 23, 2023
Merged

Add env var substitution support to file configuration#5914
jack-berg merged 2 commits into
open-telemetry:mainfrom
jack-berg:file-config-env-vars

Conversation

@jack-berg

Copy link
Copy Markdown
Member

Environment variable substitution was one of the key parts of file configuration described in the original OTEP.

I've been holding off defining it in the file configuration spec because I've been trying to define the key parse / create operations, and it makes sense to describe environment variable substitution as a requirement of parse.

So while this isn't part of the spec yet, I will be trying to get it added as soon as possible. I think the syntax of environment variables (i.e. ${env:VARIABLE_NAME}) is the most likely thing the spec lands on since its the syntax the collector uses and it will be hard to argue that an alternative new syntax would trump consistency with the collector.

@jack-berg
jack-berg requested a review from a team October 13, 2023 19:35
@codecov

codecov Bot commented Oct 13, 2023

Copy link
Copy Markdown

Codecov Report

All modified lines are covered by tests ✅

Files Coverage Δ
...ion/incubator/fileconfig/ConfigurationFactory.java 76.19% <ø> (ø)
...sion/incubator/fileconfig/ConfigurationReader.java 100.00% <100.00%> (ø)

... and 19 files with indirect coverage changes

📢 Thoughts on this report? Let us know!.

@breedx-splk breedx-splk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is great. I think users are going to get a lot of mileage out of this.

mapOf(entry("key1", "value1 value2"), entry("key2", "value2"))),
// VAR_3 is not defined in environment
Arguments.of(
"key1: ${env:VAR_3}\nkey2: value2\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These multi-line yamls that have been collapsed into a single one-line string with \n in the middle are a bit hard to read. I think a string concat would read slightly better here.

@mateuszrzeszutek mateuszrzeszutek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Do you think it'd make sense to add sth like ${sys:otel.traces.exporter} for system properties as well?

@jack-berg

Copy link
Copy Markdown
Member Author

I think we probably should @mateuszrzeszutek. Opened #5926 to discuss and track.

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.

3 participants