Skip to content

Commit

Permalink
address feedback (changelog + conditional comp)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishwesh Bankwar committed Dec 6, 2023
1 parent 7f44a77 commit 69357e8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
}

/// <summary>
Expand Down Expand Up @@ -101,13 +97,11 @@ internal AspNetCoreTraceInstrumentationOptions(IConfiguration configuration)
/// </remarks>
public bool RecordException { get; set; }

#if NET6_0_OR_GREATER
/// <summary>
/// Gets or sets a value indicating whether RPC attributes are added to an Activity when using Grpc.AspNetCore. Default is true.
/// </summary>
/// <remarks>
/// https://github.com/open-telemetry/semantic-conventions/blob/main/docs/rpc/rpc-spans.md.
/// </remarks>
internal bool EnableGrpcAspNetCoreSupport { get; set; }
#endif
}
20 changes: 11 additions & 9 deletions src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void GrpcAspNetCoreInstrumentationAddsCorrectAttributes(string enableGrpc
.AddInMemoryCollection(new Dictionary<string, string>
{
[SemanticConventionOptInKeyName] = "http",
["OTEL_DOTNET_EXPERIMENTAL_ENABLE_GRPC_INSTRUMENTATION"] = enableGrpcAspNetCoreSupport,
["OTEL_DOTNET_EXPERIMENTAL_ASPNETCORE_ENABLE_GRPC_INSTRUMENTATION"] = enableGrpcAspNetCoreSupport,
})
.Build();

Expand Down Expand Up @@ -131,7 +131,7 @@ public void GrpcAspNetCoreInstrumentationAddsCorrectAttributesWhenItCreatesNewAc
.AddInMemoryCollection(new Dictionary<string, string>
{
[SemanticConventionOptInKeyName] = "http",
["OTEL_DOTNET_EXPERIMENTAL_ENABLE_GRPC_INSTRUMENTATION"] = enableGrpcAspNetCoreSupport,
["OTEL_DOTNET_EXPERIMENTAL_ASPNETCORE_ENABLE_GRPC_INSTRUMENTATION"] = enableGrpcAspNetCoreSupport,
})
.Build();

Expand Down

0 comments on commit 69357e8

Please sign in to comment.