diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreTraceInstrumentationOptions.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreTraceInstrumentationOptions.cs index 6caadf3db90..f0fc396c969 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreTraceInstrumentationOptions.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreTraceInstrumentationOptions.cs @@ -17,9 +17,7 @@ using System.Diagnostics; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; -#if NET6_0_OR_GREATER using OpenTelemetry.Internal; -#endif namespace OpenTelemetry.Instrumentation.AspNetCore; @@ -40,12 +38,10 @@ internal AspNetCoreTraceInstrumentationOptions(IConfiguration configuration) { Debug.Assert(configuration != null, "configuration was null"); -#if NET6_0_OR_GREATER - if (configuration.TryGetBoolValue("OTEL_DOTNET_EXPERIMENTAL_ENABLE_GRPC_INSTRUMENTATION", out var enableGrpcInstrumentation)) + if (configuration.TryGetBoolValue("OTEL_DOTNET_EXPERIMENTAL_ASPNETCORE_ENABLE_GRPC_INSTRUMENTATION", out var enableGrpcInstrumentation)) { this.EnableGrpcAspNetCoreSupport = enableGrpcInstrumentation; } -#endif } /// @@ -101,7 +97,6 @@ internal AspNetCoreTraceInstrumentationOptions(IConfiguration configuration) /// public bool RecordException { get; set; } -#if NET6_0_OR_GREATER /// /// Gets or sets a value indicating whether RPC attributes are added to an Activity when using Grpc.AspNetCore. Default is true. /// @@ -109,5 +104,4 @@ internal AspNetCoreTraceInstrumentationOptions(IConfiguration configuration) /// https://github.com/open-telemetry/semantic-conventions/blob/main/docs/rpc/rpc-spans.md. /// internal bool EnableGrpcAspNetCoreSupport { get; set; } -#endif } diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md index 71d9a7bd189..6e71b160e4c 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md @@ -2,16 +2,18 @@ ## Unreleased -* Added support for gRPC instrumentation under an experimental feature flag -`OTEL_DOTNET_EXPERIMENTAL_ENABLE_GRPC_INSTRUMENTATION`. Note that the support - was removed in `1.6.0-rc.1` version of the package and versions released - before `1.6.0-rc.1` had gRPC instrumentation enabled by default. From now - onwards, gRPC instrumentation will only be enabled when - `OTEL_DOTNET_EXPERIMENTAL_ENABLE_GRPC_INSTRUMENTATION` is set to `True`. The - change is introduced in order to support stable release of `http` - instrumentation. Semantic conventions for RPC is still +* Re-introduced support for gRPC instrumentation as an opt-in experimental + feature. From now onwards, gRPC can be enabled by setting + `OTEL_DOTNET_EXPERIMENTAL_ASPNETCORE_ENABLE_GRPC_INSTRUMENTATION` to `True`. + `OTEL_DOTNET_EXPERIMENTAL_ASPNETCORE_ENABLE_GRPC_INSTRUMENTATION` can be set + as an environment variable or via IConfiguration. The change is introduced in + order to support stable release of `http` instrumentation. Semantic + conventions for RPC is still [experimental](https://github.com/open-telemetry/semantic-conventions/tree/main/docs/rpc) - and hence the package will only support it as an experimental feature. + and hence the package will only support it as an opt-in experimental feature. + Note that the support was removed in `1.6.0-rc.1` version of the package and + versions released before `1.6.0-rc.1` had gRPC instrumentation enabled by + default. ([#5130](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5130)) ## 1.6.0-rc.1 diff --git a/src/OpenTelemetry.Instrumentation.AspNetCore/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.AspNetCore/TracerProviderBuilderExtensions.cs index d61d5b6d4dd..c0cca518f40 100644 --- a/src/OpenTelemetry.Instrumentation.AspNetCore/TracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Instrumentation.AspNetCore/TracerProviderBuilderExtensions.cs @@ -76,9 +76,7 @@ public static TracerProviderBuilder AddAspNetCoreInstrumentation( services.Configure(name, configureAspNetCoreTraceInstrumentationOptions); } -#if !NETSTANDARD2_0 services.RegisterOptionsFactory(configuration => new AspNetCoreTraceInstrumentationOptions(configuration)); -#endif }); if (builder is IDeferredTracerProviderBuilder deferredTracerProviderBuilder) diff --git a/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTests.server.cs b/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTests.server.cs index 172c5e73300..b94e66f3159 100644 --- a/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTests.server.cs +++ b/test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTests.server.cs @@ -58,7 +58,7 @@ public void GrpcAspNetCoreInstrumentationAddsCorrectAttributes(string enableGrpc .AddInMemoryCollection(new Dictionary { [SemanticConventionOptInKeyName] = "http", - ["OTEL_DOTNET_EXPERIMENTAL_ENABLE_GRPC_INSTRUMENTATION"] = enableGrpcAspNetCoreSupport, + ["OTEL_DOTNET_EXPERIMENTAL_ASPNETCORE_ENABLE_GRPC_INSTRUMENTATION"] = enableGrpcAspNetCoreSupport, }) .Build(); @@ -131,7 +131,7 @@ public void GrpcAspNetCoreInstrumentationAddsCorrectAttributesWhenItCreatesNewAc .AddInMemoryCollection(new Dictionary { [SemanticConventionOptInKeyName] = "http", - ["OTEL_DOTNET_EXPERIMENTAL_ENABLE_GRPC_INSTRUMENTATION"] = enableGrpcAspNetCoreSupport, + ["OTEL_DOTNET_EXPERIMENTAL_ASPNETCORE_ENABLE_GRPC_INSTRUMENTATION"] = enableGrpcAspNetCoreSupport, }) .Build();