-
Notifications
You must be signed in to change notification settings - Fork 7
Injecting traceparent header even if no listener registered #18
Comments
Interesting, I was just copying the behavior I found in .NET Core. Here's the code for HttpClient: Do you see any major differences in why theirs would always inject the header? From the code it looks like it only includes the header if an activity is created/started. |
Without being familiar with changes of Anyways, looking closer at the link you provided I see a fallback check based on In this package, the fallback to |
Reviewing their code again, there's a LOT that changed in those classes - both for incoming and outgoing requests - for .NET 6. I'll need to revisit the logic inside in the handlers. |
I've dug some more in this and made another observations: There is a similar issue with the creation of activity in My suggestions are:
I hope that I'll find the time to create a PR with suggested changes so that we can discuss this issue based on those. |
Let me know if there is anything I can do clarify my argumentation or help out in assessing how reasonable the proposed change is! |
Have you given this any though? I understand if addressing this issue is not a priority, but it would be helpful to get an indication if it is going to be addressed at all or if we should find alternative approaches to propagating activities over NServiceBus. I believe that the changes made in #20 is still relevant and I can invest some more time in fixing the failing test if you give me some points as to how you wish to solve it. |
The next version of NServiceBus will have OTel and Activity etc out-of-the-box, so I'm going to target my next release of this package to remove any features that they have built-in. I would suggest reviewing their implementation to see if there's any similar issues. |
Thanks for getting back to me. I didn't realize that support for open telemetry and activity propagation was coming to NServiceBus. |
Ah yeah, I met with them a few times to help out. Not sure if it's exactly public but docs: https://docs.particular.net/samples/open-telemetry/ And here's the code: https://github.com/Particular/NServiceBus/tree/master/src/NServiceBus.Core/OpenTelemetry I haven't reviewed the code yet but any time a bug comes up here I ping their team in case they'll hit it too. |
We're collecting trace data using OpenTelemetry in our system that uses NServiceBus as a messaging platform. Only a small percentage of all activities are sampled, basically just enough for us to get an understanding of messages flows and bottlenecks in the system.
All log entries produced by the distributed system are enriched with trace id and span id. It is a very powerful tool to filter out logs based on this.
When trying out this package, I noticed that no header information is propagated over NServiceBus if the request isn't sampled. I believe this is due to the call to
ActivitySource.StartActivity
that returnsnull
if the the sampling result isActivitySamplingResult.None
. This, in turn, is decided by OpenTelemetry (we useParentBasedSampler
, fallbacking toAlwaysOffSampler
to make sure that we take the sampling decision at the edge). Since the activity stored inICurrentActivity
is null, no header information is injected inOutgoingPhysicalMessageDiagnostics
.So, here's the problem: Even though we only sample a small percentage of all calls in open-telemetry, it is still desirable for us to propagate tracing headers over
NServiceBus
to enrich all log entries. As things work now, the trace "chain" (typically coming over HTTP or other transports) is broken on NServiceBus publish/send.Looking forward hearing your thoughts on this!
The text was updated successfully, but these errors were encountered: