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
API to make using the request activity easier #11715
Comments
Do we need NotifyActivityChanged? Otherwise this could just be a property on the This becomes a simple HttpContext.Activity (via some feature interface, public interface IHttpActivityFeature
{
Activity Activity { get; set; }
} |
I don't think we need it. In gRPC's case we want to add metadata after the request is starting and before it is ending. The endpoint routing event you added is a good place for metadata at request start, and we don't need an event at the end because hosting raises one when it stops the activity. If app frameworks add other metadata to the activity then I guess they can raise there own specific events. |
This seems to have gotten lost and time is out. Moving to the backlog, we can consider for 3.1 or 5.0. |
A feature would be better for this. @shirhatti Thoughts? |
I like it. Let's add a feature |
Thanks for contacting us. |
Hosting sets up an activity for each request (if logging or the diagnostic listener is enabled) called
Microsoft.AspNetCore.Hosting.HttpRequestIn
Web frameworks may want to add additional data to the activity as tags for telemetry frameworks who use the activity. For example, gRPC uses a custom status trailer instead of HTTP status. Adding the status trailer to the activity would allow telemetry frameworks will recognize the request as gRPC and report the status.
Getting the request activity today is a little difficult. App frameworks would need to get the current activity from the static
Activity.Current
, then loop through the hierarchy looking for an activity calledMicrosoft.AspNetCore.Hosting.HttpRequestIn
. Once the tag has been set the framework would then need to notify the listener that the activity has been changed so telemetry frameworks can use the change immediately. DiagnosticListener isn't the easiest API to use correctly.It would be easier if there was an API for this, that was scoped per request. Something like:
An API like this would make it much easier for ASP.NET Core frameworks to reuse and enrich the existing activity, and provide a common pattern for telemetry frameworks to consume.
@davidfowl @rynowak @lmolkova
The text was updated successfully, but these errors were encountered: