Skip to content

Commit

Permalink
[ASP.NET Core] Remove grpc server instrumentation (#5097)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishweshbankwar authored Nov 29, 2023
1 parent 4f73d2b commit 39c77d4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.AspNetCoreInstrumentationOptions() -> void
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnableGrpcAspNetCoreSupport.get -> bool
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnableGrpcAspNetCoreSupport.set -> void
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithException.get -> System.Action<System.Diagnostics.Activity, System.Exception>
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithException.set -> void
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithHttpRequest.get -> System.Action<System.Diagnostics.Activity, Microsoft.AspNetCore.Http.HttpRequest>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,17 @@ public class AspNetCoreInstrumentationOptions
/// </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>
public bool EnableGrpcAspNetCoreSupport { get; set; } = true;
#endif
/*
* Removing for stable release of http instrumentation.
* grpc semantic conventions are not yet stable so this option will not be part of stable package.
#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>
public bool EnableGrpcAspNetCoreSupport { get; set; } = true;
#endif
*/
}
5 changes: 5 additions & 0 deletions src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
* Removed `netstandard2.1` target.
([#5094](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5094))

* Removed support for grpc instrumentation to unblock stable release of http
instrumentation. For details, see issue
[#5098](https://github.com/open-telemetry/opentelemetry-dotnet/issues/5098)
([#5097](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5097))

## 1.6.0-beta.3

Released 2023-Nov-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,22 +252,18 @@ public void OnStopActivity(Activity activity, object payload)
#endif

activity.SetTag(SemanticConventions.AttributeHttpResponseStatusCode, TelemetryHelper.GetBoxedStatusCode(response.StatusCode));

#if !NETSTANDARD2_0
if (this.options.EnableGrpcAspNetCoreSupport && TryGetGrpcMethod(activity, out var grpcMethod))
{
this.AddGrpcAttributes(activity, grpcMethod, context);
}
else if (activity.Status == ActivityStatusCode.Unset)
{
activity.SetStatus(SpanHelper.ResolveSpanStatusForHttpStatusCode(activity.Kind, response.StatusCode));
}
#else
/*
#if !NETSTANDARD2_0
if (this.options.EnableGrpcAspNetCoreSupport && TryGetGrpcMethod(activity, out var grpcMethod))
{
this.AddGrpcAttributes(activity, grpcMethod, context);
}
*/
if (activity.Status == ActivityStatusCode.Unset)
{
activity.SetStatus(SpanHelper.ResolveSpanStatusForHttpStatusCode(activity.Kind, response.StatusCode));
}
#endif

try
{
Expand Down
14 changes: 2 additions & 12 deletions test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTests.server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,9 @@

#if NET6_0_OR_GREATER
using System.Diagnostics;
using System.Net;
using Greet;
using Grpc.Core;
using Grpc.Net.Client;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using OpenTelemetry.Context.Propagation;
using OpenTelemetry.Instrumentation.Grpc.Services.Tests;
using OpenTelemetry.Instrumentation.GrpcNetClient;
using OpenTelemetry.Trace;
using Xunit;
using static OpenTelemetry.Internal.HttpSemanticConventionHelper;
using Status = OpenTelemetry.Trace.Status;

namespace OpenTelemetry.Instrumentation.Grpc.Tests;

Expand All @@ -46,6 +35,7 @@ public GrpcTests()
this.server = new GrpcServer<GreeterService>();
}

/*
[Theory]
[InlineData(null)]
[InlineData(true)]
Expand Down Expand Up @@ -207,7 +197,7 @@ public void GrpcAspNetCoreInstrumentationAddsCorrectAttributesWhenItCreatesNewAc
}));
}
}

*/
public void Dispose()
{
this.server.Dispose();
Expand Down

0 comments on commit 39c77d4

Please sign in to comment.