Skip to content

Metrics: data points are not cleared on collection #19

Open
@inge4pres

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

https://github.com/zig-o11y/opentelemetry-sdk/pull/14/files#diff-888687124bb8e8a88554f63e9b1ff30937ac5aa7f7298b874a3f462d6c568679R210-R219

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:

  1. ensure that the collection cycle is thread-safe, because measurementsData could be called from another thread than other modifying it
  2. 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.

Metadata

Assignees

Labels

bugSomething isn't workingmetrics

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions