-
Notifications
You must be signed in to change notification settings - Fork 505
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
Discussion: priority on environment variable vs compiling time value #1225
Comments
We discussed it in weekly meetings. Some notes
Edit (lalitb) - C++ also follow "code over env" |
I find it very confusing to make the compiled-in value take priority over the run-time value (from an environment variable). Code is usually written (and compiled) to function across many environments, whereas the runtime environment is specific to a particular invocation. Clearly the runtime environment, with its better specificity, should be trusted more than the code. Maybe we should just not provide any way to configure these values in code? Or clarify with function names etc that the values provided in code are just fallbacks if the environment doesn't provide the required information? See also this recent discussion in Cargo on a related problem: In this case, there is no value provided in code, but there's a clear hierarchy of specificity. |
I think most of people favors the environment variables. I think we can favor env vars here and make sure it's consistent. Please leave comments if you disgree @open-telemetry/rust-approvers |
So while this is not a deviation (more of a clarification), it might also be useful to document. #1297 |
FWIW I've just gotten confused by I would've instead expected having to specify some kind of (imaginary) I'm not necessarily advocating for changing this behaviour, just providing a data point from a library user. |
Reopening to further discuss given above. |
This is not consistent enforced everywhere. Adding to Log SDK stable milestone, as this is important to get closure. |
Good catch. I believe the priority order as discussed above should be
Quick look at BatchConfigBuilder , the priority order seems to be:
This needs to be fixed. Will raise an issue for this first. |
Thanks. I'd like to revisit the priority order also. Re-stating my opinion: if a user does with_xxx in code, then it should be final, and ENV variable should not override that. if user prefer ENV variable based config, then they should not do with_xxx in code and leave it untouched, so they can use ENV variable to configure things. This was never clarified in spec, so we are left with own policy, but I also want to recheck with Spec to see if there is some incoming guidance. |
Typically, environment variables are prioritized over compiled values because they allow runtime configuration without requiring recompilation. I have seen this convention more widely. Do we have a strong reason for otherwise? I can think of - malicious manipulation of environment variables, or someone leaving environment variables set by mistake - but these risks should be mitigated by proper access control and policies. |
Yes. (not sure if my opinion is a "strong" reason 🤣) Of course a lot of users prefer to have their app configured based on ENV. For those users, they can decide to not to explicitly call If we go with this, all docs for "with_**" methods for which an ENV config exists, it must be explicitly documented to users that invoking this method will seal the config, and no ENV variable can change that, and advice them to not call these methods, if they prefer ENV based configuration only. (I wish spec would have made a decision here, as without clearly specifying the priority/order across all languages, things can get very messy in polyglot environments. Will check with spec again.) |
I disagree with code choices being the final decision maker for configuration values. As an operator of software, being able to alter behaviour from the outside (eg using environment variables) at runtime is super important. Otherwise development-time choices require software to be modified (eg rebuilt) which is slow & inefficient. |
Users can decide not to programmatically configure settings, if they want to ensure ENV can be used to determine behavior without redeployment. Either way, spec has not clarified this behavior so far, leaving this up to individual implementations and is consistent across languages. |
This is I would say the common pattern and would make it very explicit, but I suppose it's a breaking change. I think this would be the optimal way to do it greenfields. Are we against this ?
I agree with this. The issue is that the call here is so explicit - "use this". Hierarchy of preference works cleanly when its all implicit - "1/ check env_1, 2/ check_file, 3/ check env_var_2" . The sort of thing you'd see with e.g. the AWS SDK credential resolution chain. https://12factor.net/config encourages the use of environment variables. The AWS SDK credential resolution process is a cool example too, I think - you either 1/ let it do magic automatic resolution, which has a hierarchy, or 2/ very explicitly use an API to specify. |
From today's SIG call: Nahum: Anton: Leaving open for 2 more days and make a final decision and implement it. |
open-telemetry/opentelemetry-specification#4413 (comment) As discussed in community call today, will leave it open for comments for another 2 days. |
Languages also supports users to config it to be auto resolved by env var. We can revert the behaivor to be by default favor compiling value but I think we should add options like |
Rust is also the same right? if user does not explicitly configure in code, then env-var is respected. (Sorry I may not have fully understood this statement!)
I am not so sure if maintaining additional complexity is worth it. For users who want env_var, they can choose to not programmatically configure it. |
open-telemetry/opentelemetry-specification#4413 (comment) Majority is treating Code over env variable. Rust looks like the odd one out now! I propose to make the change to treat code as final, and update docs/design etc. to match it. |
From community call today: Link to OTel Spec for new declarative config: open-telemetry/opentelemetry-specification#4374 |
First PR done #2781 |
This is the only Logging SDK specific change required. Removing this issue from Log SDK stable milestone. and moving to Metric SDK milestone. |
Can someone clarify for me what the current priority is and what it will be after these PRs land? |
it is not consistent today. Some prefer env some does code 😢
|
Thank you @cijothomas. That at least tells me how to prepare for the upcoming changes. Much appreciated. |
Closing this discussion as we reached an agreement on what to do. (i.e treat code as final, and higher ranked than env variables). |
Most of our creates generally allow two ways to configure values:
with_xxx
)However, this is unclear when both of the configurations present which one should take priority. Regardless we should align on this and use it as a tenet across all our creates.
cc @open-telemetry/rust-approvers
The text was updated successfully, but these errors were encountered: