Skip to content
This repository has been archived by the owner on Jul 5, 2020. It is now read-only.

AZURE SERVICEBUS - Current Activity is prematurely stopped. Should be stopped once all observers have been notified! #1038

Closed
Hyjaz opened this issue Oct 9, 2018 · 6 comments
Milestone

Comments

@Hyjaz
Copy link

Hyjaz commented Oct 9, 2018

Repro Steps

  1. Subscribe a new Observer on "Microsoft.Azure.ServiceBus"
  2. On streams of incoming events use Activity.Current to get the current activity and log some properties for the current activity, such as the Root_Id for example.

Actual Behavior

Activity.Current is null, because it is stopped on ServiceBusDiagnosticsEventHandler line 67

Expected Behavior

Activity.Current to not be null, until all observers have been notified.

Version Info

SDK Version : 2.7.2
.NET Version : netstandard2.0
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) : visual studio
OS : Windows
Hosting Info (IIS/Azure WebApps/ etc) : Console application

@Hyjaz Hyjaz changed the title Current Activity is prematurely stopped. Should be stopped once all observers have been notified! Azure ServiceBus - Current Activity is prematurely stopped. Should be stopped once all observers have been notified! Oct 9, 2018
@Hyjaz Hyjaz changed the title Azure ServiceBus - Current Activity is prematurely stopped. Should be stopped once all observers have been notified! AZURE SERVICEBUS - Current Activity is prematurely stopped. Should be stopped once all observers have been notified! Oct 9, 2018
@lmolkova
Copy link
Member

lmolkova commented Oct 9, 2018

thanks for submitting it! you are right. Here is the code responsible for it during request tracking too:

https://github.com/Microsoft/ApplicationInsights-dotnet-server/blob/develop/Src/DependencyCollector/Shared/Implementation/EventHandlers/ServiceBusDiagnosticsEventHandler.cs#L40

@Hyjaz
Copy link
Author

Hyjaz commented Oct 10, 2018

For now until this is resolved, one way to get around this, is to subscribe the custom observers that listen on Microsoft.Azure.ServiceBus before ServiceBus's observer is subscribed.

One of the problem with this workaround is that, the current activity will not have the duration. The duration will need to be calculated manually by the client.

@lmolkova lmolkova added this to the 2.9 milestone Oct 10, 2018
@lmolkova
Copy link
Member

We'll fix it in 2.9. Could you please share your scenario where you need an additional subscriber?

@Hyjaz
Copy link
Author

Hyjaz commented Oct 10, 2018

We are making use of TrackEvent so that we can pass in properties other than the ones passed by default with Microsoft.Azure.ServiceBus which makes use of the Trace api. Just a different way of tracking I guess...

@lmolkova
Copy link
Member

can you call TrackEvent during message processing, not after it or you rely on some payloads that ServiceBus sends in Stop events?

@Hyjaz
Copy link
Author

Hyjaz commented Oct 10, 2018

I rely on some payloads that ServiceBus sends in Stop events

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

No branches or pull requests

2 participants