-
Notifications
You must be signed in to change notification settings - Fork 849
Add low memory temporality for metrics #6648
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
base: main
Are you sure you want to change the base?
Add low memory temporality for metrics #6648
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6648 +/- ##
==========================================
- Coverage 86.76% 86.72% -0.04%
==========================================
Files 258 258
Lines 11958 11973 +15
==========================================
+ Hits 10375 10384 +9
- Misses 1583 1589 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
|
| private static readonly Func<Type, AggregationTemporality> LowMemoryTemporalityPreferenceFunc = (instrumentType) => | ||
| { | ||
| return instrumentType.GetGenericTypeDefinition() switch | ||
| { | ||
| var type when type == typeof(Counter<>) => AggregationTemporality.Delta, | ||
| var type when type == typeof(Histogram<>) => AggregationTemporality.Delta, | ||
|
|
||
| var type when type == typeof(UpDownCounter<>) => AggregationTemporality.Cumulative, | ||
| var type when type == typeof(ObservableCounter<>) => AggregationTemporality.Cumulative, | ||
| var type when type == typeof(ObservableUpDownCounter<>) => AggregationTemporality.Cumulative, | ||
|
|
||
| _ => AggregationTemporality.Cumulative, | ||
| }; | ||
| }; |
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 wonder if using TypeHandle property would be more performant here.
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.
Unless there's a huge benefit, I think it's better to make the code obvious by using ==. It's also not obvious from the source code what that property does differently as it just throws an exception.
| switch (instrumentName) | ||
| { | ||
| case "counter": | ||
| var counter = meter.CreateCounter<long>("test_counter"); | ||
| counter.Add(1); | ||
| break; | ||
|
|
||
| case "histogram": | ||
| var histogram = meter.CreateHistogram<long>("test_histogram"); | ||
| histogram.Record(1); | ||
| break; | ||
|
|
||
| case "updowncounter": | ||
| var upDown = meter.CreateUpDownCounter<long>("test_updown"); | ||
| upDown.Add(1); | ||
| break; | ||
|
|
||
| case "observablecounter": | ||
| meter.CreateObservableCounter("test_observable_counter", () => new Measurement<long>(1)); | ||
| break; | ||
|
|
||
| case "observableupdowncounter": | ||
| meter.CreateObservableUpDownCounter("test_observable_updown", () => new Measurement<long>(1)); | ||
| break; | ||
| } |
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.
Because the code is doing things with {Type}<>, we should probably have at least one other type in the test to verify that the equality isn't specific to a specific T.
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 added more tests
Implements #4109
Changes
Added low memory temporality as an option in the OTLP metrics exporter, following the specification
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changes