-
Notifications
You must be signed in to change notification settings - Fork 456
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
Metrics Collector: Fix adoption stats #5190
Merged
kodiakhq
merged 21 commits into
Azure:release/1.1
from
and-rewsmith:andsmi/metrics-collector-code-changes
Jul 12, 2021
Merged
Metrics Collector: Fix adoption stats #5190
kodiakhq
merged 21 commits into
Azure:release/1.1
from
and-rewsmith:andsmi/metrics-collector-code-changes
Jul 12, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
and-rewsmith
commented
Jun 30, 2021
damonbarry
previously approved these changes
Jul 2, 2021
veyalla
previously approved these changes
Jul 8, 2021
damonbarry
reviewed
Jul 8, 2021
damonbarry
requested changes
Jul 8, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you describe (maybe in the PR description) what you're achieving by using a semaphore?
damonbarry
reviewed
Jul 8, 2021
…d-rewsmith/iotedge into andsmi/metrics-collector-code-changes
and-rewsmith
commented
Jul 8, 2021
and-rewsmith
commented
Jul 8, 2021
damonbarry
approved these changes
Jul 8, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We removed the test specific logic from the metrics collector. In doing so, this removed a get twin call that was relied on for gauging usage stats.
The solution is to recreate the
ModuleClient
(after product info and potentially all other fields are set) even in the Log Analytics code path. This change needs some synchronization as to not interfere with metrics potentially being published from theIotMessage
metrics upload path (which also usesModuleClient
).To achieve this synchronization, I chose to create a wrapper around the
ModuleClient
which serves as the shared reference across multipleTasks
. Multiple of theseTasks
might use theModuleClient
. OneTask
could be recreating it while the other could be attempting to publish messages. In order to achieve synchronization I chose to use aSemaphoreSlim
because I needed some async lock.I ran into some issues when attempting to recreate the
ModuleClient
.CloseAsync()
the SDK threw an exception. (SDK bug imo)I managed to resolve these issues by not calling
CloseAsync()
and waiting 1 minute to publish messages. I confirmed inEdgeHub
logs that multiple connections did not exist.