Propagate trace context for gRPC calls - #1858
Conversation
|
@mtaghavi2005 I just noticed this PR. I'm working on an improvement to add integration testing for these spans so this stops becoming a recurring issue as part of your ask in #1867. Some of your code looks awfully similar to my own, so I'm going to put this PR on hold until I merge my changes (as I've already got a fix and a test for your issue). We can circle back afterwards to see whether this change is still necessary. Sorry I didn't see it sooner to use instead as a starting point! |
|
No problem, and thanks a lot for the update! That makes sense. I’m also glad to hear that the other issue will be resolved soon. Looking forward to taking another look once your changes are merged. |
|
That’s great news! Thank you for the update. I'm also looking forward to seeing all the tracing issues, especially those related to workflows, resolved. I really appreciate all your effort and support! I'll test the changes from master (or the upcoming patch release), and if everything looks good, I'll close this PR. |
|
I was able to repro this locally - going to poke at it later this and next week. |
|
@mtaghavi2005 I just wanted to give an update - I'm still looking into this. Historically, none of the SDKs are instrumented at all and we instead direct anyone to consume the otel endpoint from the runtime to get this information. This PR validates that workflows capture e2e (though I'll certainly update it to reflect the other SDK functionality as well) via that OTEL endpoint as expected, but it occurs to me that the issue might lie in how Aspire auto-instruments the application (e.g. it's not consuming from the Dapr OTEL endpoint, but rather capturing from the gRPC and HTTP requests leaving the SDK itself, which is why it has that incomplete picture. Rather than just patching this on the SDK and opening up a can of worms of enabling at-dev-time telemetry capture via Aspire that's entirely unintended for production usage (again, should be using the rutnime's endpoint), I'm looking into whether I can configure Aspire to instead visualize the telemetry from the Dapr runtime as that would be more aligned with our best practices generally. Also, I'll be out of the office next week, so I likely won't have another update until the first week of August. |
|
Thanks for the update. I agree with the distinction here: I am not trying to make the Dapr .NET SDK produce its own telemetry spans for normal client operations. The issue I am trying to separate is context propagation, not SDK instrumentation. It is also not limited to workflows; it is a general gRPC tracing/context propagation issue for Dapr .NET SDK calls to the sidecar. From my investigation, Aspire can show a correct-looking trace when
I also traced this further and found that the Dapr runtime can extract the incoming So I agree the ideal fix is probably upstream in The reason I still think SDK-side Regarding Aspire: I agree it may be showing an incomplete picture if it is observing app HTTP/gRPC instrumentation instead of consuming the Dapr runtime OTEL endpoint. To avoid mixing Aspire-specific behavior with production behavior, I can also verify the same scenario with Application Insights without using aspire by comparing:
That should make it clearer whether the remaining issue is only Aspire visualization, runtime OTEL consumption/configuration, or actual context propagation from the .NET app to the sidecar. |
|
Fair enough - I appreciate the evidence backing your solution. If you can clean up the merge conflicts, I'm happy to merge your PR as-is. |
cd92855 to
1a011f9
Compare
Signed-off-by: Mohammad Taghavi <mtaghavi2005@gmail.com>
1a011f9 to
4e52167
Compare
|
@WhitWaldo I updated the PR and the merge conflicts are resolved now. There are still a few failing integration checks. I’m not sure yet whether they are related to this PR or CI/environment issues, so I’ll leave them for your review. |
|
@mtaghavi2005 We have a few lingering issues with GitHub and the CI checks running in parallel (lots of port exhaustion) - it's a known issue, but really low on my priority list since that "re-run jobs" button is easy enough to just keep clicking). I've got this merged and I'll see about getting a patch released this evening. Thank you very much for all your time and effort into this. |




Description
Propagates trace context on gRPC calls so Dapr sidecar spans can preserve the expected parent-child relationship with the application operation that initiated the call.
This adds
grpc-trace-binmetadata from the current .NET activity when available, and includes tests for the shared gRPC call options path andDaprClientpublish flow.Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #1857
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: