NServiceBus Sample Throws Exception

This tracing sample:


throws an exception upon execution. To see it, you have to disable the “Enable Just My Code” debugging option as well as have all Common Language Runtime Exceptions enabled in the Exception Settings dialog.

The issue is that the same Activity is started twice, first in MessageTracing.cs at line 44 and again in NserviceBusTracingListener.cs at line 32. It seems to be a benign error but does indicate that the there is no need to start the activity twice.

HI @MarkBricker,

thank you for sharing your analysis. The reason for current behavior is (as you mention) that the same activity is started twice. We need to start the activity in MessageTracing as we need the activity identifier so that we can put it in the headers of the outgoing message.

At the same time StartOperation<> on the TelemetryClient that we call in NServiceBusTracingLister tries to open the activity again and this causes internal exceptions to be thrown and immediately swallowed.

In summary, I think there is not much that we can do as long as the Activity class sticks to the design for how duplicated calls to Start are handled.