Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

WIP: Fix header propagation #20

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pardahlman
Copy link

This PR aims to address the issues in #18.

I'm confident in the changes made in the outgoing behaviors and I have verified that an activity with correct TraceId and SpanId is created when the code enters the new if block in IncomingPhysicalMessageDiagnostics.

However, I have not tried the flow with listeners registered to the ActivitySource. But as this code is untouched, I assume it works as expected. Perhaps there is a way to restructure the control flow?

I note that two unit tests are failing. This is due to 85bdb7f and the fact that the test relied on Activity.Current, not the activity passed in the message context. I fixed one test, and be happy to amend it to the previous commit. However, want your input on how to fix the other test. In this case the ICurrentActivity is set on IOutgoingLogicalMessageContext. but the test creates a new IOutgoingPhysicalMessageContext that does not contain that activity.

This is done for two reasons:

1. OutgoingLogicalMessageDiagnostics always adds ICurrentActivity to the
   outgoing message context, and thus the TryGet will always return true
   making it so that the value of Activity.Curent will never be
   retrieved

2. With the update to OutgoingLogicalMessageDiagnostics, the
   ICurrentActivity will contain a child activity to Activity.Current
   even if there are no listeners to the event source.
The call to NServiceBusActivitySource.ActivitySource.StartActivity
returns null if no listeners are registered.

This change makes it so that an activity is created if the parentId
header contains valid data for the creation of ActivityContext.

It also sets the parent based on TraceId and SpanId, making the created
activity belong to the correct trace etc.
The test depended on Activity.Current fallback, which has been removed
in previous commit.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant