Skip to content
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

System.Diagnostics.Activity not started when handling delayed messages with open telemetry enabled #7209

Open
jonesr-out opened this issue Nov 12, 2024 · 4 comments

Comments

@jonesr-out
Copy link

Describe the bug

Description

System.Diagnostics.Activity.Current is null when trying to access this property within a command handler for commands sent with a delay. The behavior is only seen in versions later than NServiceBus 9.0.4. It works as expected in version 9.0.4.

Expected behavior

System.Diagnostics.Activity.Current should not be null since a new span should have been created.

Actual behavior

System.Diagnostics.Activity.Current is null.

Versions

NServiceBus >= 9.0.5

Steps to reproduce

The issue is reproducible running this sample application, https://github.com/jonesr-out/nservicebus-otel-bug. Note that MessageGenerator is setting a 100ms delay using DelayDeliveryWith.

image

image

Relevant log output

No response

Additional Information

Workarounds

  • Downgrade to version 1.0.4
@jonesr-out jonesr-out added the Bug label Nov 12, 2024
@TravisNickels
Copy link
Member

TravisNickels commented Nov 12, 2024

Thanks for reporting this. We are going to take a look at this and try to reproduce and triage it. We will let you know what the results are.

@boblangley
Copy link
Member

We've validated the bug and added it to our priority bug backlog and will work on it as soon as we can.

@ydie22
Copy link

ydie22 commented Jan 3, 2025

I think the activity is being discarded by sampling.
activity = ActivitySources.Main.StartActivity(name: ActivityNames.IncomingMessageActivityName, ActivityKind.Consumer, CreateNewRootActivityContext(), tags: null, links: links); returns null. Maybe the trace flags should include Recorded ?
Also, further in the code, an attempt to start the resulting activity is made, which is an error given the StartActivity call (also setting the ID format is prohibited on already started activities).

@mauroservienti
Copy link
Member

Quick update: #7264 has been raised to address this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants