Skip to content

Commit

Permalink
fix: fix that metrics aggregation @data_points.clear will cause hdps …
Browse files Browse the repository at this point in the history
…cleared (#1532)

* fix: fix that metrics aggregation @data_points.clear will cause hdps cleared

* fix: use map!

---------

Co-authored-by: Robert <robertlaurin@users.noreply.github.com>
  • Loading branch information
xuan-cao-swi and robertlaurin authored Dec 7, 2023
1 parent 3eb59d5 commit dc215ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ def initialize(
def collect(start_time, end_time)
if @aggregation_temporality == :delta
# Set timestamps and 'move' data point values to result.
hdps = @data_points.each_value do |hdp|
hdps = @data_points.values.map! do |hdp|
hdp.start_time_unix_nano = start_time
hdp.time_unix_nano = end_time
hdp
end
@data_points.clear
hdps
Expand Down
3 changes: 2 additions & 1 deletion metrics_sdk/lib/opentelemetry/sdk/metrics/aggregation/sum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ def initialize(aggregation_temporality: :delta)
def collect(start_time, end_time)
if @aggregation_temporality == :delta
# Set timestamps and 'move' data point values to result.
ndps = @data_points.each_value do |ndp|
ndps = @data_points.values.map! do |ndp|
ndp.start_time_unix_nano = start_time
ndp.time_unix_nano = end_time
ndp
end
@data_points.clear
ndps
Expand Down

0 comments on commit dc215ff

Please sign in to comment.