-
Notifications
You must be signed in to change notification settings - Fork 785
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
Add optional tags support to TracerProvider.GetTracer for .NET 9 #6111
base: main
Are you sure you want to change the base?
Add optional tags support to TracerProvider.GetTracer for .NET 9 #6111
Conversation
The committers listed above are authorized under a signed CLA. |
@@ -27,6 +27,50 @@ protected TracerProvider() | |||
/// </summary> | |||
public static TracerProvider Default { get; } = new TracerProvider(); | |||
|
|||
#if NET9_0_OR_GREATER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for introducing the new API in .NET 9 or later?
/// <param name="version">Version of the instrumentation library.</param> | ||
/// <param name="tags">Tags associated with the tracer.</param> | ||
/// <returns>Tracer instance.</returns> | ||
public Tracer GetTracer( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #6016
Design discussion issue #6016
Changes
This PR introduces support for adding default tags to a specific
Tracer
by leveraging the newActivitySource
constructor overload in .NET 9, which acceptsIEnumerable<KeyValuePair<string, object?>>? tags
. The changes include:Added a new overload for
TracerProvider.GetTracer
in .NET 9 and above, which accepts an optionaltags
parameter.Extended the
TracerKey
record struct to include theTags
property for .NET 9 and above, ensuring that tracers with differenttags
are uniquely identified.Updated the
Tracer
creation logic to pass thetags
parameter to theActivitySource
constructor when applicable.Maintained backward compatibility for pre-.NET 9 environments by keeping the existing
GetTracer
method without thetags
parameter.These changes align with the feature request to support default tags for specific tracers, similar to the enhancements made in
System.Diagnostics.ActivitySource
.Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes