question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] - Trace ParentId is not restored from Diagnostic-Id message property

See original GitHub issue

Library name and version

Azure.Messaging.ServiceBus 7.10.0

Describe the bug

I’m investigating W3C context propagation over ServiceBus. It looks like message sent correctly with valid Diagnostic-Id is not correlated correcly during the message read handling. For both servicebusreceiver.receive and servicebusprocessor.processmessage operations the ParentId property is null. Because of that, these operations are reported as separated traces instead of one trace, started on the web api request.

different parent ids

I tried to set ParentId manually with lines like:

    private async Task ProcessorOnProcessMessageAsync(ProcessMessageEventArgs arg)
    {
        var bodyAsString = arg.Message.Body.ToString();
        var diagnosticsId = arg.Message.ApplicationProperties["Diagnostic-Id"].ToString();
        using var activity = new Activity("ServiceBusProcessor.processing");
        activity.SetParentId(diagnosticsId);
        activity.Start();

        [...]
        activity.Stop();
    }

but it moves only user-code to the correct trace. Both servicebusreceiver.receive and servicebusprocessor.processmessage operations are received outside of the flow image

Expected behavior

ServiceBus reader (both processor and receiver) should use TraceId from Diagnostic-Id as a ParentTraceId

Actual behavior

servicebusreceiver.receive and servicebusprocessor.processmessage don’t read ParentTraceId

Reproduction Steps

Available at https://github.com/lukasz-pyrzyk/opentelemetry-demo, API and webjob project, together with HTTP request to start the flow.

Environment

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jsquirecommented, Sep 20, 2022

Is there a chance that the article comes from the times of Microsoft.Azure.Servicebus, where this approach was used

I don’t know the origin of the article nor who maintains it, but the code samples appear to have been updated for the current generation and I notice that our telemetry expert is listed as a contributor. @lmolkova: Would you be so kind as to offer your thoughts?

0reactions
msftbot[bot]commented, Sep 27, 2022

Hi @lukasz-pyrzyk, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong ParentId in ASP.NET Core 3.1?
I'm testing how tracing works in ASP.NET Core 3.1 and something is not working. I have 3 ASP.NET Core apps (Node1, Node2, ...
Read more >
Azure Service Bus end-to-end tracing and diagnostics
Overview of Service Bus client diagnostics and end-to-end tracing (client through all the services that are involved in processing.)
Read more >
MyGeotab API Adapter - Solution and Implementation Guide
The adapter is a collection of NET 6.0 Worker Services (C#) that interface between the MyGeotab API and the database, essentially pulling data...
Read more >
Mattermost self-hosted changelog
auto-recover : If the migration plan receives an error during migrations, this command will try to rollback migrations already applied within the plan....
Read more >
Mattermost mobile apps changelog
Fixed an issue where the app did not now show an error when adding servers without a diagnostic ID. Fixed an issue where...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found