Skip to content

Commit 39c77d4

Browse files
[ASP.NET Core] Remove grpc server instrumentation (#5097)
1 parent 4f73d2b commit 39c77d4

File tree

5 files changed

+28
-35
lines changed

5 files changed

+28
-35
lines changed

src/OpenTelemetry.Instrumentation.AspNetCore/.publicApi/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions
22
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.AspNetCoreInstrumentationOptions() -> void
3-
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnableGrpcAspNetCoreSupport.get -> bool
4-
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnableGrpcAspNetCoreSupport.set -> void
53
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithException.get -> System.Action<System.Diagnostics.Activity, System.Exception>
64
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithException.set -> void
75
OpenTelemetry.Instrumentation.AspNetCore.AspNetCoreInstrumentationOptions.EnrichWithHttpRequest.get -> System.Action<System.Diagnostics.Activity, Microsoft.AspNetCore.Http.HttpRequest>

src/OpenTelemetry.Instrumentation.AspNetCore/AspNetCoreInstrumentationOptions.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,17 @@ public class AspNetCoreInstrumentationOptions
7777
/// </remarks>
7878
public bool RecordException { get; set; }
7979

80-
#if NET6_0_OR_GREATER
81-
/// <summary>
82-
/// Gets or sets a value indicating whether RPC attributes are added to an Activity when using Grpc.AspNetCore. Default is true.
83-
/// </summary>
84-
/// <remarks>
85-
/// https://github.com/open-telemetry/semantic-conventions/blob/main/docs/rpc/rpc-spans.md.
86-
/// </remarks>
87-
public bool EnableGrpcAspNetCoreSupport { get; set; } = true;
88-
#endif
80+
/*
81+
* Removing for stable release of http instrumentation.
82+
* grpc semantic conventions are not yet stable so this option will not be part of stable package.
83+
#if NET6_0_OR_GREATER
84+
/// <summary>
85+
/// Gets or sets a value indicating whether RPC attributes are added to an Activity when using Grpc.AspNetCore. Default is true.
86+
/// </summary>
87+
/// <remarks>
88+
/// https://github.com/open-telemetry/semantic-conventions/blob/main/docs/rpc/rpc-spans.md.
89+
/// </remarks>
90+
public bool EnableGrpcAspNetCoreSupport { get; set; } = true;
91+
#endif
92+
*/
8993
}

src/OpenTelemetry.Instrumentation.AspNetCore/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
* Removed `netstandard2.1` target.
1212
([#5094](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5094))
1313

14+
* Removed support for grpc instrumentation to unblock stable release of http
15+
instrumentation. For details, see issue
16+
[#5098](https://github.com/open-telemetry/opentelemetry-dotnet/issues/5098)
17+
([#5097](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5097))
18+
1419
## 1.6.0-beta.3
1520

1621
Released 2023-Nov-17

src/OpenTelemetry.Instrumentation.AspNetCore/Implementation/HttpInListener.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -252,22 +252,18 @@ public void OnStopActivity(Activity activity, object payload)
252252
#endif
253253

254254
activity.SetTag(SemanticConventions.AttributeHttpResponseStatusCode, TelemetryHelper.GetBoxedStatusCode(response.StatusCode));
255-
256-
#if !NETSTANDARD2_0
257-
if (this.options.EnableGrpcAspNetCoreSupport && TryGetGrpcMethod(activity, out var grpcMethod))
258-
{
259-
this.AddGrpcAttributes(activity, grpcMethod, context);
260-
}
261-
else if (activity.Status == ActivityStatusCode.Unset)
262-
{
263-
activity.SetStatus(SpanHelper.ResolveSpanStatusForHttpStatusCode(activity.Kind, response.StatusCode));
264-
}
265-
#else
255+
/*
256+
#if !NETSTANDARD2_0
257+
258+
if (this.options.EnableGrpcAspNetCoreSupport && TryGetGrpcMethod(activity, out var grpcMethod))
259+
{
260+
this.AddGrpcAttributes(activity, grpcMethod, context);
261+
}
262+
*/
266263
if (activity.Status == ActivityStatusCode.Unset)
267264
{
268265
activity.SetStatus(SpanHelper.ResolveSpanStatusForHttpStatusCode(activity.Kind, response.StatusCode));
269266
}
270-
#endif
271267

272268
try
273269
{

test/OpenTelemetry.Instrumentation.Grpc.Tests/GrpcTests.server.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,9 @@
1616

1717
#if NET6_0_OR_GREATER
1818
using System.Diagnostics;
19-
using System.Net;
20-
using Greet;
21-
using Grpc.Core;
22-
using Grpc.Net.Client;
23-
using Microsoft.Extensions.Configuration;
24-
using Microsoft.Extensions.DependencyInjection;
2519
using Moq;
26-
using OpenTelemetry.Context.Propagation;
2720
using OpenTelemetry.Instrumentation.Grpc.Services.Tests;
28-
using OpenTelemetry.Instrumentation.GrpcNetClient;
29-
using OpenTelemetry.Trace;
3021
using Xunit;
31-
using static OpenTelemetry.Internal.HttpSemanticConventionHelper;
32-
using Status = OpenTelemetry.Trace.Status;
3322

3423
namespace OpenTelemetry.Instrumentation.Grpc.Tests;
3524

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

38+
/*
4939
[Theory]
5040
[InlineData(null)]
5141
[InlineData(true)]
@@ -207,7 +197,7 @@ public void GrpcAspNetCoreInstrumentationAddsCorrectAttributesWhenItCreatesNewAc
207197
}));
208198
}
209199
}
210-
200+
*/
211201
public void Dispose()
212202
{
213203
this.server.Dispose();

0 commit comments

Comments
 (0)