Skip to content

Commit

Permalink
Always set otel.status_code (#22115)
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym authored Jun 23, 2021
1 parent 50c62cc commit be4174d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ private async ValueTask ProcessAsync(HttpMessage message, ReadOnlyMemory<HttpPip
{
activity.AddTag("otel.status_code", "ERROR");
}
else
{
// Set the status to UNSET so the AppInsights doesn't try to infer it from the status code
activity.AddTag("otel.status_code", "UNSET");
}
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/Azure.Core/tests/RequestActivityPolicyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public async Task ActivityIsCreatedForRequest()
CollectionAssert.Contains(activity.Tags, new KeyValuePair<string, string>("http.user_agent", "agent"));
CollectionAssert.Contains(activity.Tags, new KeyValuePair<string, string>("requestId", clientRequestId));
CollectionAssert.Contains(activity.Tags, new KeyValuePair<string, string>("serviceRequestId", "server request id"));
CollectionAssert.Contains(activity.Tags, new KeyValuePair<string, string>("otel.status_code", "UNSET"));
CollectionAssert.Contains(activity.Tags, new KeyValuePair<string, string>("kind", "client"));
CollectionAssert.Contains(activity.Tags, new KeyValuePair<string, string>("az.namespace", "Microsoft.Azure.Core.Cool.Tests"));
CollectionAssert.DoesNotContain(activity.Tags.Select(t=>t.Key), "otel.status_code");
}

[Test]
Expand Down

0 comments on commit be4174d

Please sign in to comment.