-
Notifications
You must be signed in to change notification settings - Fork 891
[OpenTelemetry] Remove vendored EnvironmentVariablesConfigurationProvider #7146
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| using OpenTelemetry.Tests; | ||
| using OpenTelemetry.Trace; | ||
| using Xunit; | ||
|
|
||
| namespace OpenTelemetry.Resources.Tests; | ||
|
|
||
| [Collection(EnvVarsCollectionDefinition.Name)] | ||
| public sealed class EnvironmentVariableResourceIntegrationTests | ||
| { | ||
| [Fact] | ||
| public void TracerProvider_PopulatesResourceFromEnvironmentVariables() | ||
| { | ||
| // End-to-end smoke for the env-var > IConfiguration > Resource chain used by | ||
| // ResourceBuilderExtensions.AddEnvironmentVariableDetector. Drives real OTEL | ||
| // spec variables through ResourceBuilder.CreateDefault and reads the live | ||
| // Resource off the built TracerProvider. Catches any regression that breaks | ||
| // the pipeline between Environment and the SDK's exported resource. | ||
| using (new EnvironmentVariableScope("OTEL_SERVICE_NAME", "e2e-env-var-service")) | ||
|
Check failure on line 21 in test/OpenTelemetry.Tests/Resources/EnvironmentVariableResourceIntegrationTests.cs
|
||
| using (new EnvironmentVariableScope("OTEL_RESOURCE_ATTRIBUTES", "deployment.environment=test,region=eu-west")) | ||
|
Check failure on line 22 in test/OpenTelemetry.Tests/Resources/EnvironmentVariableResourceIntegrationTests.cs
|
||
| { | ||
| using var tracerProvider = Sdk.CreateTracerProviderBuilder().Build(); | ||
|
|
||
| var attributes = tracerProvider.GetResource().Attributes; | ||
|
|
||
| Assert.Contains(new KeyValuePair<string, object>("service.name", "e2e-env-var-service"), attributes); | ||
| Assert.Contains(new KeyValuePair<string, object>("deployment.environment", "test"), attributes); | ||
| Assert.Contains(new KeyValuePair<string, object>("region", "eu-west"), attributes); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| using Xunit; | ||
|
|
||
| namespace OpenTelemetry.Tests; | ||
|
|
||
| /// <summary> | ||
| /// Serialization anchor for tests that mutate process-global environment | ||
| /// variables. Tests that set or clear env vars should carry | ||
| /// <c>[Collection(EnvVarsCollectionDefinition.Name)]</c> so they run | ||
| /// sequentially with each other, avoiding cross-class races on shared env | ||
| /// var state. | ||
| /// </summary> | ||
| [CollectionDefinition(Name, DisableParallelization = true)] | ||
| #pragma warning disable CA1515 // xUnit1027 requires [CollectionDefinition] classes to be public. | ||
| public sealed class EnvVarsCollectionDefinition | ||
| #pragma warning restore CA1515 | ||
| { | ||
| public const string Name = "EnvVars"; | ||
| } | ||
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.
@martincostello, as I remember you have implemented scope tools for testing env vars. Can it be used instead of adding collections?
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.
If EnvironmentVariableScope is being used we shouldn't need to use it, unless there's a lot of parallelism going on.