-
Notifications
You must be signed in to change notification settings - Fork 847
Add support for OTEL_SDK_DISABLED environment variable #6568
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
base: main
Are you sure you want to change the base?
Add support for OTEL_SDK_DISABLED environment variable #6568
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6568 +/- ##
==========================================
- Coverage 86.67% 86.32% -0.36%
==========================================
Files 258 258
Lines 11895 11910 +15
==========================================
- Hits 10310 10281 -29
- Misses 1585 1629 +44
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…ahhaering/opentelemetry-dotnet into support-sdk-disabled-envVar
test/OpenTelemetry.Tests/Logs/LoggerProviderBuilderBaseTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Martin Costello <[email protected]>
public LoggerProviderBuilderBaseTests() | ||
{ | ||
Environment.SetEnvironmentVariable(SdkConfigDefinitions.SdkDisableEnvVarName, null); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Environment.SetEnvironmentVariable(SdkConfigDefinitions.SdkDisableEnvVarName, null); | ||
GC.SuppressFinalize(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.
A better way to do this, IMHO, would be to:
- Not set the value in the constructor
- Let the test set the value it's interested in
- Set it back to the original value when being disposed
You could use a similar pattern to this to implement it in a cross-cutting way, then the usage would be something like:
using (new EnvironmentVariableScope("OTEL_SDK_DISABLED", value))
{
var builder = new LoggerProviderBuilderBase();
using var provider = builder.Build();
Assert.IsType(expected, provider);
}
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.
Thanks for the suggestion, I've done that.
Is there any way I can retry the workflow without a commit? Sometimes the build fails even though I have no errors (like right now).
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.
Not without write access to the repo, no.
test/OpenTelemetry.Tests/Logs/LoggerProviderBuilderBaseTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Martin Costello <[email protected]>
Implements #4155
Changes
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes