-
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
Open
hannahhaering
wants to merge
14
commits into
open-telemetry:main
Choose a base branch
from
hannahhaering:support-sdk-disabled-envVar
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+131
−1
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3603f51
add support for OTEL_SDK_DISABLED environment variable
hannahhaering 947fcb1
added changelog entry
hannahhaering ba7d7ae
fix environment variable parsing
hannahhaering 6244098
Merge branch 'main' into support-sdk-disabled-envVar
hannahhaering ae28768
retry workflow
hannahhaering 583b34b
Merge branch 'support-sdk-disabled-envVar' of https://github.com/hann…
hannahhaering ca695bf
Merge branch 'main' into support-sdk-disabled-envVar
hannahhaering bbf01d4
parameterize tests for OTEL_SDK_DISABLED
hannahhaering d35a343
Update src/OpenTelemetry/CHANGELOG.md
hannahhaering c51cd9e
parameterize tests for OTEL_SDK_DISABLED
hannahhaering 0aa2dc3
Merge branch 'main' into support-sdk-disabled-envVar
hannahhaering ecacbf2
Add helper and refactor tests for sdk disabled env var
hannahhaering 86b050b
Merge branch 'main' into support-sdk-disabled-envVar
hannahhaering d35c752
Update test/OpenTelemetry.Tests/Logs/LoggerProviderBuilderBaseTests.cs
hannahhaering File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
namespace OpenTelemetry; | ||
|
||
internal static class SdkConfigDefinitions | ||
{ | ||
public const string SdkDisableEnvVarName = "OTEL_SDK_DISABLED"; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
internal sealed class EnvironmentVariableScope : IDisposable | ||
{ | ||
private readonly string name; | ||
private readonly string? previous; | ||
|
||
public EnvironmentVariableScope(string name, string? value) | ||
{ | ||
this.name = name; | ||
this.previous = Environment.GetEnvironmentVariable(name); | ||
Environment.SetEnvironmentVariable(name, value); | ||
} | ||
|
||
public void Dispose() => Environment.SetEnvironmentVariable(this.name, this.previous); | ||
} |
26 changes: 26 additions & 0 deletions
26
test/OpenTelemetry.Tests/Logs/LoggerProviderBuilderBaseTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using Xunit; | ||
using static OpenTelemetry.OpenTelemetrySdk; | ||
|
||
namespace OpenTelemetry.Logs.Tests; | ||
|
||
public sealed class LoggerProviderBuilderBaseTests | ||
{ | ||
[Theory] | ||
[InlineData("true", typeof(NoopLoggerProvider))] | ||
[InlineData("false", typeof(LoggerProviderSdk))] | ||
[InlineData(null, typeof(LoggerProviderSdk))] | ||
public void LoggerProviderIsExpectedType(string? value, Type expected) | ||
{ | ||
using (new EnvironmentVariableScope("OTEL_SDK_DISABLED", value)) | ||
{ | ||
var builder = new LoggerProviderBuilderBase(); | ||
|
||
using var provider = builder.Build(); | ||
|
||
Assert.IsType(expected, provider); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
test/OpenTelemetry.Tests/Metrics/MeterProviderBuilderBaseTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using Xunit; | ||
using static OpenTelemetry.OpenTelemetrySdk; | ||
|
||
namespace OpenTelemetry.Metrics.Tests; | ||
|
||
public sealed class MeterProviderBuilderBaseTests | ||
{ | ||
[Theory] | ||
[InlineData("true", typeof(NoopMeterProvider))] | ||
[InlineData("false", typeof(MeterProviderSdk))] | ||
[InlineData(null, typeof(MeterProviderSdk))] | ||
public void LoggerProviderIsExpectedType(string? value, Type expected) | ||
{ | ||
using (new EnvironmentVariableScope("OTEL_SDK_DISABLED", value)) | ||
{ | ||
var builder = new MeterProviderBuilderBase(); | ||
|
||
using var provider = builder.Build(); | ||
|
||
Assert.IsType(expected, provider); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.