-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[docs/rfc] RFC about environment variables #9854
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9854 +/- ##
==========================================
- Coverage 91.95% 91.70% -0.25%
==========================================
Files 357 358 +1
Lines 16501 16543 +42
==========================================
- Hits 15173 15171 -2
- Misses 1000 1045 +45
+ Partials 328 327 -1 ☔ View full report in Codecov by Sentry. |
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.
Self-reviewing to start some threads about topics I want to discuss
docs/rfcs/env-vars.md
Outdated
When an invalid identifier is found, a warning log is emitted, and the | ||
string is kept as-is. |
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.
I am undecided about this, I feel like we should fail in some cases but I am not sure about which. open-telemetry/opentelemetry-specification/issues/3981 has some more discussion about this
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.
I agree with aligning with the configuration spec and I hope that ends up being failing. I think failing fast is a clearer outcome for the user.
For users that mis-typed the env var name, keeping the string verbatim could mean an unintuitive error caused by the unwanted string. If we fail immediately we can log a clear error message that will be easier to troubleshoot.
If the user needs an illegal string like ${env:this-is-illegal}
they can use the escape to make it exact: $${env:this-is-illegal}
.
To summarize: using the env var syntax is a request to parse an env var - if the provided env var cannot be parsed we should fail.
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.
@TylerHelmuth The one edge case here is ${1}
from open-telemetry/opentelemetry-collector-contrib/issues/9984. Should we fail in that case and force uses to use escaping syntax?
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.
Since that is what we currently do and it seems impossible to detect all kinds of syntaxes past or future that would overlap with this, I have changed this to an error on 3f05467
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.
@mx-psi I feel like since ${1}
corresponds with the regex it should be expanded. If users need the literal ${1}
can they do $${1}
?
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.
I feel like since ${1} corresponds with the regex it should be expanded
I think we are on the same page, but to be clear 1
is not a valid identifier per the 'desired behavior' section (valid identifiers need to start with underscore or ASCII alphabetic characters), so it should not be expanded, but rather raise an error.
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.
Ah ok, then we are on the same page, I just got the outcome wrong. My opinion is the ${1}
should fail and if users need that literal string they should escape: $${1}
.
This prevents us from having any edge cases with our unwrap syntax while keeping all functionality available.
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.
@mx-psi where in the spec do we need to raise this issue?
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.
Tyler and I discussed this offline but for the benefit of anybody else keeping track of this: this is being discussed on open-telemetry/opentelemetry-specification/pull/4002
| `0123` | string | 0123 | 83 | 0123 | 0123 | | ||
| `0xdeadbeef` | string | 0xdeadbeef | 3735928559 | 0xdeadbeef | 0xdeadbeef | | ||
| `"0123"` | string | "0123" | 0123 | 0123 | 0123 | | ||
| `!!str 0123` | string | !!str 0123 | 0123 | 0123 | 0123 | |
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.
For 'Desired behavior, inline string field' here, the behavior of the File Configuration SDK would be to set !!str 0123
. I think this is a rare edge case, but as written it would set 0123
since the AsString
method would not return the original representation
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.
For 'Desired behavior, inline string field' here, the behavior of the File Configuration SDK would be to set
!!str 0123
.
Can you link to where this is defined? I can't see where this is addressed this outside of declaring a suggested minimum version of the YAML spec.
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.
I think the closest one would be the combo_string_key
from https://opentelemetry.io/docs/specs/otel/configuration/file-configuration/#environment-variable-substitution
I take this to mean that the original value passed by the user on the environment variable should be preserved as is when you use expansion inline
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.
I vote we stick with whatever the configuration sig is doing
Co-authored-by: Alex Boten <[email protected]>
Co-authored-by: Evan Bradley <[email protected]>
Co-authored-by: Alex Boten <[email protected]>
docs/rfcs/env-vars.md
Outdated
When an invalid identifier is found, a warning log is emitted, and the | ||
string is kept as-is. |
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.
I agree with aligning with the configuration spec and I hope that ends up being failing. I think failing fast is a clearer outcome for the user.
For users that mis-typed the env var name, keeping the string verbatim could mean an unintuitive error caused by the unwanted string. If we fail immediately we can log a clear error message that will be easier to troubleshoot.
If the user needs an illegal string like ${env:this-is-illegal}
they can use the escape to make it exact: $${env:this-is-illegal}
.
To summarize: using the env var syntax is a request to parse an env var - if the provided env var cannot be parsed we should fail.
Make an invalid identifier an explicit error
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.
LGTM
Remaining work
|
|
||
The naked syntax supported in BASH is not supported in the Collector. | ||
Escaping is supported by using two dollar signs. Escaping is also | ||
honored for unsupported identifiers like `${1}` (i.e. anything that |
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.
Based on our discussion in this thread this sentence should be updated to clarify that ${1}
is no supported.
docs/rfcs/env-vars.md
Outdated
When an invalid identifier is found, a warning log is emitted, and the | ||
string is kept as-is. |
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.
@mx-psi where in the spec do we need to raise this issue?
Co-authored-by: Evan Bradley <[email protected]>
@mx-psi it looks like the spec issue will merge within the next 2 days, is the second issue still blocking this work? |
@codeboten I haven't written a fully working PoC yet. I am fine merging this without the PoC if everybody else is okay with it (it may mean minor changes while we work on implementing this) |
Let's merge this and change it as needed, the spec change was merged 👍🏻 |
**Description:** Adds an RFC about how environment variable resolution should work **Link to tracking Issue:** Fixes open-telemetry#9515, relates to: - open-telemetry#8215 - open-telemetry#8565 - open-telemetry#9162 - open-telemetry#9531 - open-telemetry#9532 --------- Co-authored-by: Alex Boten <[email protected]> Co-authored-by: Evan Bradley <[email protected]>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description <!-- Issue number if applicable --> Adds tests of current type casting behavior when using env and file provider. #### Link to tracking issue Relates to #9854, #8565, #9532
#### Description <!-- Issue number if applicable --> - Add `confmap.strictlyTypedInput` feature gate that introduces stricter type checks when resolving configuration - Make `confmap.NewRetrievedFromYAML` function public so that external providers have consistent behavior when resolving YAML - Adds `confmap.Retrieved.AsString` method to retrieve string representation for retrieved values #### Link to tracking issue Relates to #9854, updates #8565, #9532
Description: Adds an RFC about how environment variable resolution should work
Link to tracking Issue: Fixes #9515, relates to:
$
doesn't work when passed via${env:DB_PASSWORD}
#8215$
is used in config for env var expansion #9162