-
Notifications
You must be signed in to change notification settings - Fork 279
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
Add GC heap size and count in Runtime metrics #412
Conversation
Codecov Report
@@ Coverage Diff @@
## main #412 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 155 155
Lines 4776 4784 +8
=====================================
- Misses 4776 4784 +8
|
Measurement<long>[] measurements = new Measurement<long>[NumberOfGenerations]; | ||
for (int i = 0; i < measurements.Length; i++) | ||
{ | ||
measurements[i] = new Measurement<long>(GC.CollectionCount(i), new KeyValuePair<string, object>("gen", HeapNames[i])); |
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.
"gen" might be too "generic" ?
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.
I think it won't be if it appears together with a value from ("gen0", "gen1", "gen2", "loh", "poh"). However I'm ok to better name suggestions like "generation" or "generationName".
Can I keep it as is and update this attribute key accordingly once #404 is finalized?
…ntelemetry-dotnet-contrib into xiang17/addGCCounter # Conflicts: # src/OpenTelemetry.Instrumentation.Runtime/CHANGELOG.md
… avoid allocation on each collect
…ntelemetry-dotnet-contrib into xiang17/addGCCounter
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.
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.
LGTM with some nonblocking clarification questions / suggestions.
# Conflicts: # src/OpenTelemetry.Instrumentation.Runtime/CHANGELOG.md # src/OpenTelemetry.Instrumentation.Runtime/RuntimeMetrics.cs
return new[] | ||
var generationInfo = GC.GetGCMemoryInfo().GenerationInfo; | ||
|
||
Measurement<long>[] measurements = new Measurement<long>[generationInfo.Length]; |
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.
This will cause allocation. We could either use a pre allocated array/list or make use of the yield return
semantic.
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.
This metrics is an Observable and gets called once every 15~20 seconds. So it's not worth doing too much optimization for now. Most importantly, if there are multiple readers reading it at almost the same time, they could have incorrect values from reading pre allocated shared array.
I've tried to use yield return
and it worked for two other methods, however, for this one I got an error. See discussion thread at #412 (comment)
The compile will fail with GetGarbageCollectionHeapSizes because it needs a
Span<T>
: "CS4013 Instance of type 'ReadOnlySpan' cannot be used inside a nested function, query expression, iterator block or async method".
* Add `gc.heapsize` and change `gc.count` to multi-dimensional metrics
Fixes #335.
Changes
Add
gc.heapsize
and changegc.count
to multi-dimensional metricsFor significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes