Skip to content
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

Move env-var read logic to common dir, and optional reading of env-var #924

Merged
merged 9 commits into from
Aug 2, 2021

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented Jul 26, 2021

Changes

  1. Move env var reading logic to sdk::common namespace, this allows it to be reused at multiple places.
  2. Optional reading of env variables based on macro -DNO_GETENV. The env var is not read if the macro is set. This allows using sdk with platforms like UWP which doesn't support env variables. ( as discussed in Allow to programmatically populate settings for OTELResourceDetector #656 ).
  3. Make required otlp-grpc exporter options to be read through env variable, which further allows loading this exporter at run-time using the dynamic-load plugin. This would be further added for other exporters also.

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@lalitb lalitb requested a review from a team July 26, 2021 05:26
@codecov
Copy link

codecov bot commented Jul 26, 2021

Codecov Report

Merging #924 (b1fe988) into main (a9b2f9f) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #924      +/-   ##
==========================================
+ Coverage   95.36%   95.36%   +0.01%     
==========================================
  Files         159      160       +1     
  Lines        6775     6779       +4     
==========================================
+ Hits         6460     6464       +4     
  Misses        315      315              
Impacted Files Coverage Δ
sdk/test/resource/resource_test.cc 93.46% <ø> (ø)
...k/include/opentelemetry/sdk/common/env_variables.h 100.00% <100.00%> (ø)
sdk/src/resource/resource_detector.cc 100.00% <100.00%> (ø)

{
constexpr char kOtlpGrpcIsSslEnableEnv[] = "OTEL_EXPORTER_OTLP_GRPC_SSL_ENABLE";
auto ssl_enable = opentelemetry::sdk::common::GetEnvironmentVariable(kOtlpGrpcIsSslEnableEnv);
if (ssl_enable == "True" || ssl_enable == "TRUE" || ssl_enable == "true" || ssl_enable == "1")
Copy link
Contributor

Choose a reason for hiding this comment

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

Convert it to lower case before comparison, to make the comparison case insensitive?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point will change that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok. I realize there is no method available in stdlib to perform this conversion. we have to iterate over the string to convert it. The existing comparison looks simple as compared to that :)

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jul 31, 2021

CLA Signed

The committers are authorized under a signed CLA.

@lalitb
Copy link
Member Author

lalitb commented Aug 2, 2021

/easycla

@lalitb lalitb merged commit 5067e49 into open-telemetry:main Aug 2, 2021
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.

2 participants