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

Fix race condition in generic diagnostic listener#948

Merged
lmolkova merged 4 commits into
developfrom
lmolkova/FixRaceConditionInServiceBus
Jul 10, 2018
Merged

Fix race condition in generic diagnostic listener#948
lmolkova merged 4 commits into
developfrom
lmolkova/FixRaceConditionInServiceBus

Conversation

@lmolkova
Copy link
Copy Markdown

@lmolkova lmolkova commented Jul 7, 2018

When generic diagnostic listener subscribes to DiagnosticSource, it attempts to use this in its own constructor, while some properties (filters) are not initialized yet.

As a result, if DiagnosticSource is created BEFORE the generic listener, it's guaranteed to miss subscription event and never receive anything.

This PR fixes this issue.

  • I ran Unit Tests locally.

For significant contributions please make sure you have completed the following items:

  • Changes in public surface reviewed

  • Design discussion issue #

  • CHANGELOG.md updated with one line description of the fix, and a link to the original issue.

  • The PR will trigger build, unit tests, and functional tests automatically. If your PR was submitted from fork - mention one of committers to initiate the build for you.
    If you want to to re-run the build/tests, the easiest way is to simply Close and Re-Open this same PR. (Just click 'close pull request' followed by 'open pull request' buttons at the bottom of the PR)

  • Please follow [these] (https://github.com/Microsoft/ApplicationInsights-dotnet-server/blob/develop/CONTRIBUTING.md) instructions to build and test locally.

@lmolkova
Copy link
Copy Markdown
Author

lmolkova commented Jul 7, 2018

Please ignore build failure, it was cancelled, re-started and passed, but github did not pick up successful run

this.Client = new TelemetryClient(configuration);
}

public void Subscribe()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this public method, can you please add a

describing What this is, Why this is?

@cijothomas cijothomas closed this Jul 9, 2018
@cijothomas cijothomas reopened this Jul 9, 2018
private IDisposable listenerSubscription;
private List<IDisposable> individualSubscriptions;

protected DiagnosticSourceListenerBase(TelemetryConfiguration configuration)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the Subscribe method is required, should we make a reference to it in the constructor?
I don't know how often a developer creates a new DiagnosticSourceListener (probably not often :) ), but I wonder that they may not know to look for the Subscribe method.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an internal class, it's only us who call this method and just once. I can add the comment, though

@lmolkova lmolkova merged commit 0b30363 into develop Jul 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants