-
Notifications
You must be signed in to change notification settings - Fork 402
[AspNetCore] Update gRPC Semantic Conventions #4370
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
Merged
martincostello
merged 15 commits into
open-telemetry:main
from
martincostello:update-aspnetcore-grpc-semantic-conventions
Jun 17, 2026
Merged
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2629aa6
[AspNetCore] Optimize HttpInListener
martincostello f930f0d
[AspNetCore] Update gRPC Semantic Conventions
martincostello f8dbbe6
[AspNetCore] Update grpc tag removal
martincostello 92b7911
Merge branch 'main' into update-aspnetcore-grpc-semantic-conventions
martincostello c31fe87
[Instrumentation.AspNetCore] Move RPC helper
martincostello 3349be6
Merge branch 'main' into update-aspnetcore-grpc-semantic-conventions
martincostello bcba1cf
[AspNetCore] Address feedback
martincostello dac78d2
Merge branch 'main' into update-aspnetcore-grpc-semantic-conventions
martincostello c23ae0e
[AspNetCore] Fix merge
martincostello 07eb7a8
Merge branch 'main' into update-aspnetcore-grpc-semantic-conventions
martincostello daebfb7
[AspNetCore] Address feedback
martincostello 054ec2e
[AspNetCore] Remove RPC new/old opt-in
martincostello 84b1573
[AspNetCore] Remove RpcSemanticConventionHelper
martincostello 0fd8c86
[AspNetCore] Address feedback
martincostello 74bc6ec
Fix gRPC span name for unrecognized methods
Kielek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
martincostello marked this conversation as resolved.
Outdated
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| using System.Diagnostics.CodeAnalysis; | ||
| using Microsoft.Extensions.Configuration; | ||
|
|
||
| namespace OpenTelemetry.Internal; | ||
|
|
||
| /// <summary> | ||
| /// Helper class for RPC Semantic Conventions. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// Due to a breaking change in the semantic conventions, affected instrumentation libraries | ||
| /// must inspect an environment variable to determine which attributes to emit. | ||
| /// This is expected to be removed when the instrumentation libraries reach Stable. | ||
| /// <see href="https://github.com/open-telemetry/semantic-conventions/blob/v1.23.0/docs/rpc/rpc-spans.md"/>. | ||
| /// <see href="https://github.com/open-telemetry/semantic-conventions/blob/v1.41.0/docs/rpc/rpc-spans.md"/>. | ||
| /// </remarks> | ||
| internal static class RpcSemanticConventionHelper | ||
| { | ||
| internal const string SemanticConventionOptInKeyName = "OTEL_SEMCONV_STABILITY_OPT_IN"; | ||
| internal static readonly char[] Separator = [',', ' ']; | ||
|
|
||
|
martincostello marked this conversation as resolved.
Outdated
|
||
| [Flags] | ||
| internal enum RpcSemanticConvention | ||
| { | ||
| /// <summary> | ||
| /// Instructs an instrumentation library to emit the old experimental RPC attributes. | ||
| /// </summary> | ||
| Old = 0x1, | ||
|
|
||
| /// <summary> | ||
| /// Instructs an instrumentation library to emit the new, v1.23.0 RPC attributes. | ||
| /// </summary> | ||
| New = 0x2, | ||
|
|
||
| /// <summary> | ||
| /// Instructs an instrumentation library to emit both the old and new attributes. | ||
| /// </summary> | ||
| Dupe = Old | New, | ||
| } | ||
|
|
||
| public static RpcSemanticConvention GetSemanticConventionOptIn(IConfiguration configuration) | ||
| { | ||
| if (TryGetConfiguredValues(configuration, out var values)) | ||
| { | ||
| if (values.Contains("rpc/dup")) | ||
| { | ||
| return RpcSemanticConvention.Dupe; | ||
| } | ||
| else if (values.Contains("rpc")) | ||
| { | ||
| return RpcSemanticConvention.New; | ||
| } | ||
| } | ||
|
|
||
| return RpcSemanticConvention.Old; | ||
| } | ||
|
|
||
| private static bool TryGetConfiguredValues(IConfiguration configuration, [NotNullWhen(true)] out HashSet<string>? values) | ||
| { | ||
| try | ||
| { | ||
| var stringValue = configuration[SemanticConventionOptInKeyName]; | ||
|
|
||
| if (string.IsNullOrWhiteSpace(stringValue)) | ||
| { | ||
| values = null; | ||
| return false; | ||
| } | ||
|
|
||
| #pragma warning disable IDE0370 // Suppression is unnecessary | ||
| var stringValues = stringValue!.Split(separator: Separator, options: StringSplitOptions.RemoveEmptyEntries); | ||
| #pragma warning restore IDE0370 // Suppression is unnecessary | ||
| values = new HashSet<string>(stringValues, StringComparer.OrdinalIgnoreCase); | ||
| return true; | ||
| } | ||
| catch | ||
| { | ||
| values = null; | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.