Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,6 @@ project:
notices](./THIRD-PARTY-NOTICES.TXT) file in the repository, as needed.

See
[EnvironmentVariablesExtensions.cs](./src/Shared/EnvironmentVariables/EnvironmentVariablesExtensions.cs)
[NullableAttributes.cs](./src/Shared/Shims/NullableAttributes.cs)
for an example of a file copied from another project and attributed in the [3rd
party notices](./THIRD-PARTY-NOTICES.TXT) file.
4 changes: 4 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,29 @@
-->
<ItemGroup>
<!-- Default to latest versions for all TFMs -->
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="[10.0.0,)" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="[10.0.0,)" />
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Abstractions" Version="[10.0.0,)" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="[10.0.0,)" />
<PackageVersion Include="Microsoft.Extensions.Logging.Configuration" Version="[10.0.0,)" />
</ItemGroup>
<!-- Version overrides for specific netX.0 TFMs -->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageVersion Update="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="[8.0.0,)" />
<PackageVersion Update="Microsoft.Extensions.DependencyInjection.Abstractions" Version="[8.0.0,)" />
<PackageVersion Update="Microsoft.Extensions.Diagnostics.Abstractions" Version="[8.0.0,)" />
<PackageVersion Update="Microsoft.Extensions.Hosting.Abstractions" Version="[8.0.0,)" />
<PackageVersion Update="Microsoft.Extensions.Logging.Configuration" Version="[8.0.0,)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageVersion Update="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="[9.0.0,)" />
<PackageVersion Update="Microsoft.Extensions.DependencyInjection.Abstractions" Version="[9.0.0,)" />
<PackageVersion Update="Microsoft.Extensions.Diagnostics.Abstractions" Version="[9.0.0,)" />
<PackageVersion Update="Microsoft.Extensions.Hosting.Abstractions" Version="[9.0.0,)" />
<PackageVersion Update="Microsoft.Extensions.Logging.Configuration" Version="[9.0.0,)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageVersion Update="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="[10.0.0,)" />
<PackageVersion Update="Microsoft.Extensions.DependencyInjection.Abstractions" Version="[10.0.0,)" />
<PackageVersion Update="Microsoft.Extensions.Diagnostics.Abstractions" Version="[10.0.0,)" />
<PackageVersion Update="Microsoft.Extensions.Hosting.Abstractions" Version="[10.0.0,)" />
Expand Down
5 changes: 0 additions & 5 deletions OpenTelemetry.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,6 @@
<File Path="src/Shared/Configuration/IConfigurationExtensionsLogger.cs" />
<File Path="src/Shared/Configuration/OpenTelemetryConfigurationExtensions.cs" />
</Folder>
<Folder Name="/Shared/EnvironmentVariables/">
<File Path="src/Shared/EnvironmentVariables/EnvironmentVariablesConfigurationProvider.cs" />
<File Path="src/Shared/EnvironmentVariables/EnvironmentVariablesConfigurationSource.cs" />
<File Path="src/Shared/EnvironmentVariables/EnvironmentVariablesExtensions.cs" />
</Folder>
<Folder Name="/Shared/Metrics/">
<File Path="src/Shared/Metrics/Base2ExponentialBucketHistogramHelper.cs" />
</Folder>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</ItemGroup>

<ItemGroup Condition="'$(RunningDotNetPack)' == 'true'">
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
Comment thread
stevejgordon marked this conversation as resolved.
<PackageReference Include="OpenTelemetry" />
</ItemGroup>

Expand Down
6 changes: 6 additions & 0 deletions src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Notes](../../RELEASENOTES.md).
* The library is now marked as trim and AOT compatible.
([#7441](https://github.com/open-telemetry/opentelemetry-dotnet/pull/7441))

* Dropped the vendored `EnvironmentVariablesConfigurationProvider` copy; the
provider is now sourced transitively from the
`Microsoft.Extensions.Configuration.EnvironmentVariables` package referenced
by `OpenTelemetry`. No public API or behavioural change.
([#7146](https://github.com/open-telemetry/opentelemetry-dotnet/pull/7146))
Comment thread
martincostello marked this conversation as resolved.

## 1.16.0

Released 2026-Jun-10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" />
<Compile Include="$(RepoRoot)\src\Shared\ResourceSemanticConventions.cs" Link="Includes\ResourceSemanticConventions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\ActivityHelperExtensions.cs" Link="Includes\ActivityHelperExtensions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\EnvironmentVariables\*.cs" Link="Includes\EnvironmentVariables\%(Filename).cs" />
<Compile Include="$(RepoRoot)\src\Shared\ExceptionExtensions.cs" Link="Includes\ExceptionExtensions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\Shims\Lock.cs" Link="Includes\Shims\Lock.cs" />
<Compile Include="$(RepoRoot)\src\Shared\Options\*.cs" Link="Includes\Options\%(Filename).cs" />
Expand Down
7 changes: 7 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ Notes](../../RELEASENOTES.md).
* The library is now marked as trim and AOT compatible.
([#7441](https://github.com/open-telemetry/opentelemetry-dotnet/pull/7441))

* Replaced the vendored copy of
Comment thread
martincostello marked this conversation as resolved.
`EnvironmentVariablesConfigurationProvider` with a direct
`Microsoft.Extensions.Configuration.EnvironmentVariables` package dependency.
Consumers gain automatic pickup of upstream bug fixes and security patches;
no public API or behavioural change.
([#7146](hhttps://github.com/open-telemetry/opentelemetry-dotnet/pull/7146))

## 1.16.0

Released 2026-Jun-10
Expand Down
2 changes: 1 addition & 1 deletion src/OpenTelemetry/OpenTelemetry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" />
</ItemGroup>
Expand All @@ -19,7 +20,6 @@
<ItemGroup>
<Compile Include="$(RepoRoot)\src\Shared\AssemblyVersionExtensions.cs" Link="Includes\AssemblyVersionExtensions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\Configuration\*.cs" Link="Includes\Configuration\%(Filename).cs" />
<Compile Include="$(RepoRoot)\src\Shared\EnvironmentVariables\*.cs" Link="Includes\EnvironmentVariables\%(Filename).cs" />
<Compile Include="$(RepoRoot)\src\Shared\MathHelper.cs" Link="Includes\MathHelper.cs" />
<Compile Include="$(RepoRoot)\src\Shared\Options\*.cs" Link="Includes\Options\%(Filename).cs" />
<Compile Include="$(RepoRoot)\src\Shared\ResourceSemanticConventions.cs" Link="Includes\ResourceSemanticConventions.cs" />
Expand Down

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,31 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using OpenTelemetry.Trace;

namespace OpenTelemetry.Resources.Tests;

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 (EnvironmentVariableScope.Create([
("OTEL_SERVICE_NAME", "e2e-env-var-service"),
("OTEL_RESOURCE_ATTRIBUTES", "deployment.environment=test,region=eu-west")]))
{
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
Expand Up @@ -2,9 +2,11 @@
// SPDX-License-Identifier: Apache-2.0

using Microsoft.Extensions.Configuration;
using OpenTelemetry.Tests;

namespace OpenTelemetry.Resources.Tests;

[Collection(EnvVarsCollectionDefinition.Name)]
public sealed class OtelEnvResourceDetectorTests : IDisposable
{
public OtelEnvResourceDetectorTests()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
// SPDX-License-Identifier: Apache-2.0

using Microsoft.Extensions.Configuration;
using OpenTelemetry.Tests;

namespace OpenTelemetry.Resources.Tests;

[Collection(EnvVarsCollectionDefinition.Name)]
public sealed class OtelServiceNameEnvVarDetectorTests : IDisposable
{
public OtelServiceNameEnvVarDetectorTests()
Expand Down
19 changes: 19 additions & 0 deletions test/OpenTelemetry.Tests/Shared/EnvVarsCollectionDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

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
Comment thread
martincostello marked this conversation as resolved.
#pragma warning restore CA1515
{
public const string Name = "EnvVars";
}