Description
Describe the current state
With the changes proposed in #14 we switch from aggregating data when the instruments are recording a data point to aggregating when collection happens by a MetricReader
.
That said, we haven't added a way to discard the data points that are collected from the reader.
e.g. in Counter measurementsData
we fetch all the data points from the measurements
arraylist, but then we don't remove them from the arraylist, letting it ever growing.
This is similar in all other instruments.
Describe the desired state
We should:
- ensure that the collection cycle is thread-safe, because
measurementsData
could be called from another thread than other modifying it - clean up the items fetched for collection from the state of the instrument
For point 2., we could use toOwnedSlice()
but we should first understand if the allocator that is passed as part of the collection is the same used for recording datapoints (unlikely).
If we want to keep a clean separation between the allocators, copying in place the items seems to be simplest solution.