Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Instrumentation.GrpcCore] Remove usage of "otel.status_code" and "otel.status_description" #1799

Merged
3 changes: 3 additions & 0 deletions src/OpenTelemetry.Instrumentation.GrpcCore/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
([#1624](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1624))
* Update `OpenTelemetry.Api` to `1.8.1`.
([#1668](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1668))
* Use `Activity.Status` and `Activity.StatusDescription`
instead of `otel.status_code` and `otel.status_description` tags.
([#1799](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1799))

## 1.0.0-beta.5

Expand Down
3 changes: 1 addition & 2 deletions src/OpenTelemetry.Instrumentation.GrpcCore/RpcScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Threading;
using Google.Protobuf;
using Grpc.Core;
using OpenTelemetry.Trace;

namespace OpenTelemetry.Instrumentation.GrpcCore;

Expand Down Expand Up @@ -104,7 +103,7 @@
}

// The overall Span status should remain unset however the grpc status code attribute is required
this.StopActivity((int)Grpc.Core.StatusCode.OK);

Check warning on line 106 in src/OpenTelemetry.Instrumentation.GrpcCore/RpcScope.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

Name can be simplified
}

/// <summary>
Expand All @@ -118,7 +117,7 @@
return;
}

var grpcStatusCode = Grpc.Core.StatusCode.Unknown;

Check warning on line 120 in src/OpenTelemetry.Instrumentation.GrpcCore/RpcScope.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

Name can be simplified
var description = exception.Message;

if (exception is RpcException rpcException)
Expand All @@ -139,7 +138,7 @@
}

// If not already completed this will mark the Activity as cancelled.
this.StopActivity((int)Grpc.Core.StatusCode.Cancelled);

Check warning on line 141 in src/OpenTelemetry.Instrumentation.GrpcCore/RpcScope.cs

View workflow job for this annotation

GitHub Actions / lint-dotnet-format / run-dotnet-format

Name can be simplified
}

/// <summary>
Expand Down Expand Up @@ -184,7 +183,7 @@
this.activity.SetTag(SemanticConventions.AttributeRpcGrpcStatusCode, statusCode);
if (statusDescription != null)
{
this.activity.SetStatus(Trace.Status.Error.WithDescription(statusDescription));
this.activity.SetStatus(ActivityStatusCode.Error, statusDescription);
}

this.activity.Stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ internal static class SemanticConventions
public const string AttributeMessageID = "message.id";
public const string AttributeMessageCompressedSize = "message.compressed_size";
public const string AttributeMessageUncompressedSize = "message.uncompressed_size";
public const string AttributeOtelStatusCode = "otel.status_code";
public const string AttributeOtelStatusDescription = "otel.status_description";

// Used for unit testing only.
internal const string AttributeActivityIdentifier = "activityidentifier";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static void ValidateNewTagOnActivity(InterceptorActivityListener listener)
// Cancelled is not an error.
if (expectedStatusCode != StatusCode.OK && expectedStatusCode != StatusCode.Cancelled)
{
Assert.Contains(activity.TagObjects, t => t.Key == SemanticConventions.AttributeOtelStatusCode && (string)t.Value == "ERROR");
Assert.Equal(ActivityStatusCode.Error, activity.Status);
}

if (recordedMessages)
Expand Down Expand Up @@ -490,7 +490,7 @@ private static async Task TestHandlerSuccess(Func<Foobar.FoobarClient, Metadata,

if (validateErrorDescription)
{
Assert.Contains(activity.TagObjects, t => t.Key == SemanticConventions.AttributeOtelStatusDescription && ((string)t.Value).Contains("fubar"));
Assert.Contains("fubar", activity.StatusDescription);
}
}

Expand Down
Loading