Add IsMetricAlreadyCaptured to IMetricsProvider #745
Merged
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.
Solves #729
Prior to GC metrics, all metrics were captured "on the fly", meaning the agent periodically collected metrics (let's say every 30 seconds) and metrics providers were queried for data when the agent wanted to collect the data.
But this does not work in all cases. For collecting GC metrics we subscribe to EventSource (or ETW on Full Framework + Windows) and the GC triggers a method when a GC happens and that is our chance to collect data. GC is just 1 example, I expect similar situations later with other metrics.
It can happen that no GC is triggered for let's say 5 minutes - each time the agent tries to collect data before the 1. GC, it won't see any data.
The
MetricsCollector
wrongly disabled collecting metrics in such cases - so GC metrics were disabled forever for the given process.Therefore a
bool
propertyIsMetricAlreadyCaptured
is added toIMetricsProvider
. Until this property does not return true,MetricsCollector
won't try to get data from a metrics provider and won't disable it either - it just skips it. The newIsMetricAlreadyCaptured
should be set totrue
when theIMetricsProvider
tried to query data or was triggered by e.g. ETW or EventSource the 1. time.