-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Allow additional Tags for activity creation #50488
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
Comments
What do you think about renaming the two methods to /// <summary>
/// Defines a feature to enrich activities with additional tags.
/// </summary>
public interface IHttpActivityEnrichmentFeature
{
/// <summary>
/// Called during the creation of an activity.
/// </summary>
/// <param name="context">The current HTTP context.</param>
ActivityTagsCollection ActivityCreating(HttpContext context);
/// <summary>
/// Called after an activity has been created to perform further enrichment.
/// </summary>
/// <param name="activity">The created activity.</param>
/// <param name="context">The current HTTP context.</param>
void ActivityCreated(Activity activity, HttpContext context);
} This convention is already used in some places like https://github.com/dotnet/efcore/blob/main/src/EFCore.Relational/Diagnostics/IDbConnectionInterceptor.cs. |
Taking a look at this. Maybe that extra work of setting it twice, only for the sampled Activity case, isn't that big of a deal? |
Adding feature as a hook for users to be able to specify what tags should be added on creation |
Uh oh!
There was an error while loading. Please reload this page.
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
When doing sampling with Activity/Traces, the information that you have to make the decision on whether to Sample or Drop is only that which is passed in as tags to Start/CreateActivity method. Sampling at the Head (root activity) is the most efficient method as it allows child activitys to inherit that decision and therefore reduce processing. You can sample at an individual (child) activity level too.
Right now, there is very little information to go on when trying to apply Head Sampling in a .NET application. This is because of the Activity being created having no tags being used as part of the Create.
aspnetcore/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs
Line 389 in 2f7a3f7
This means that the samplers can only base their decision on the parent context.
In order to use other contextual information, you need to use something like the IHttpContextAccessor to access the ambient context.
Describe the solution you'd like
What would make this better from a consumer perspective would be an extension point to augment the activity tags at creation time.
I don't know if Features for HTTP are available to get during the pipeline, however, something like the following
This would allow users to do that enrichment at the right time. It would allow the level of data being used to be configured according to the performance concerns of the user.
Additional context
No response
The text was updated successfully, but these errors were encountered: