-
Notifications
You must be signed in to change notification settings - Fork 773
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 Copy methods to MetricPoint and HistogramBuckets to facilitate deep-copying #3113
add Copy methods to MetricPoint and HistogramBuckets to facilitate deep-copying #3113
Conversation
This reverts commit 9dcb839.
Codecov Report
@@ Coverage Diff @@
## main #3113 +/- ##
==========================================
+ Coverage 84.68% 84.72% +0.04%
==========================================
Files 259 259
Lines 9213 9232 +19
==========================================
+ Hits 7802 7822 +20
+ Misses 1411 1410 -1
|
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
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 is Part1 to address #2361.
Changes
MetricPoint
andHistogramBuckets
.MetricPoint.histogramBuckets
Please provide a brief description of the changes here.
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changesDiscussion
This design is based on my original PoC (#2907) and examples shared by @CodeBlanch (https://github.com/open-telemetry/opentelemetry-dotnet/compare/main...CodeBlanch:inmemory-metrics-copy?expand=1).
The end goal is to enable the
InMemoryExporter
to deep-copying Metrics.I looked doing copying only in the InMemoryExporter, but this would require exposing private members.
This PR is the smallest possible change to facilitate copying.
Because we're adding this to the
OpenTelemetry
library, I ran some Benchmarks.I evaluated manual copying vs using MemberwiseClone.
I determined that manually copying theMetricPoint
and using MemberwiseClone onHistogramBuckets
created the fewest allocations.MemberwiseClone does NOT deep copy nested references, and the manual copy is necessary here. Unit tests validate this behavior.
Benchmark code