-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Propagate trace parent to SignalR hub invocations #57049
Conversation
/// <summary> | ||
/// Create an activity with details received from a remote source. | ||
/// </summary> | ||
public static Activity? CreateFromRemote( |
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.
This centralizes and shares ASP.NET Core's code for created an activity from a remote source. Now used by ASP.NET Core hosting and SignalR.
4c2649e
to
cfc30b1
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
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.
LGTM
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.
I was kind of expecting the Javascript client to be done as well. It's the most used client (.NET is second) and we generally like to add new features to both JS and .NET to have some verification that the concept works across languages.
...server/SignalR/test/Microsoft.AspNetCore.SignalR.Tests/HubConnectionHandlerTests.Activity.cs
Show resolved
Hide resolved
I've never done OTEL from JavaScript before. I don't know if I'd have time to do it for .NET 9. What would you like to do? Note, there will probably be some dependencies required for working with OTEL in JavaScript. In .NET we have APIs built into runtime for this stuff. JavaScript requires packages, e.g. https://www.npmjs.com/package/@opentelemetry/core for setting propagated headers. And a higher level OTEL packages for setting a client span if that's also in the JavaScript client. |
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.
LGTM as well.
@tarekgh - in a future release we might want to offer an improved overload of ActivitySource.CreateActivity so that callers don't need these workarounds. It looks like one extra parameter to specify HasRemoteParent and a 2nd to allow creating an activity even when there is no listener would probably reduce the calling code by ~75 lines.
@BrennanConroy I have a PR for adding a client activity source and activities in #57101. That PR uses this one as its target branch. Please take some time to see if there are any outstanding changes required or whether it is ok to merge. That will allow the client activity source PR to be retargeted to main. |
eff6c7e
to
2f4adcc
Compare
Addresses #51557. Specifically, the Distributed tracing (trace ids sent between client and server) item.
Follow up to #55439. The previous PR added activities for signalr server invocations. However, the server hub invocation activity never has a parent, so the activity always starts a new trace. This PR updates signalr to get trace information from the hub invocation message headers, which are set by the client, when it creates the activity.
The benefit of this change is you can now see the context of the hub invocation. For example, if web api sends a hub invocation to SignalR, the hub invocation span is nested beneath the web api span.
Changes:
Not planned in this PR:
Nothing is blocking these from being added in the future.
TODO: Write tests for client. Write integration test for client to server.