-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Custom Request-Id for client side requests #38850
Comments
Client as in JavaScript or .NET client? |
Javascript client, calling this service from the UI. This way we would be able to track down the whole path of a request coming from the browser. |
It can be customized, I just need to find the example. Here's the code in hosting, it uses a DistributedContextPropagator. aspnetcore/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs Lines 286 to 292 in 73db5e4
The only reference I can find is https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-7/#libraries-system-diagnostics-propagators, but @noahfalk would know better. |
This should be possible custom "propagators" (dotnet/runtime#50658). The default propagator respects the W3CTraceContext spec, i.e it looks for "traceparent" header (with a fallback to "request-id" to maintain back compact with legacy header). |
@cijothomas do you have any pointers to some documentation? |
Nothing other than the design proposal : dotnet/runtime#50658 (comment) |
Thanks for contacting us. We're moving this issue to the |
Thank you all for the help here, I will analyze the source code in order to understand how to provide a custom propagator. Some documentation would be nice to have though. |
@tarekgh @MihaZupan - did any documentation ever get created for the propagators feature? For example it would be ideal to have it documented together with our existing distributed tracing docs. In the meantime if there are no docs I think the short story is roughly:
public override void ExtractTraceIdAndState(object? carrier, PropagatorGetterCallback? getter, out string? traceId, out string? traceState)
{
if (getter is null)
{
traceId = null;
traceState = null;
return;
}
getter(carrier, "MySpecialIdHeader", out traceId, out _);
traceState = null;
} If you need to handle the new header in addition to messages that use other more typical headers you can also consider falling back to check other headers when this one isn't present. Also update the Fields property to enumerate any header names you might want to look up per-request.
|
We have documented the APIs here. Having a conceptual doc for propagators is a good idea too. |
Reading through this now, I don't think there's any work in ASP.NET Core for this so I'll close the issue. @tarekgh You may want to file a tracking item in runtime's docs for the conceptual doc on propagators. |
On every new request, aspnetcore creates a new Activity and sets a RequestId, TraceId, and SpanId, and spans it through the logs.
Is it possible to somehow set the ParentId to a UUID coming from the client-side (javascript) via a custom HTTP header?
I understand that if this UUID comes in the Request-Id HTTP header it automatically uses it, but what if it comes in a different custom header?
Thank you.
The text was updated successfully, but these errors were encountered: