File tree Expand file tree Collapse file tree 4 files changed +11
-8
lines changed Expand file tree Collapse file tree 4 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 55- Added ` Resource::get_ref(&self, key: &Key) -> Option<&Value> ` to allow retrieving a reference to a resource value without cloning.
66- ** Breaking** Removed the following public hidden methods from the ` SdkTracer ` [ #3227 ] [ 3227 ] :
77 - ` id_generator ` , ` should_sample `
8+ - ** Fix** : ObservableCounter and ObservableUpDownCounter now correctly report only data points from the current measurement cycle,
9+ removing stale attribute combinations that are no longer observed. This fixes [ #3213 ] ( 3213 )
10+ where dynamic attributes (e.g., client connections with changing IPs/ports) would accumulate historical data indefinitely.
11+ Both Delta and Cumulative temporality modes now use ` collect_and_reset ` internally to clean up unobserved attributes.
812
913[ 3227 ] : https://github.com/open-telemetry/opentelemetry-rust/pull/3227
1014
Original file line number Diff line number Diff line change @@ -116,8 +116,10 @@ impl<T: Number> PrecomputedSum<T> {
116116 s_data. temporality = Temporality :: Cumulative ;
117117 s_data. is_monotonic = self . monotonic ;
118118
119+ // Use collect_and_reset to remove stale attributes (not observed in current callback)
120+ // For cumulative, report absolute values (no delta calculation needed)
119121 self . value_map
120- . collect_readonly ( & mut s_data. data_points , |attributes, aggr| SumDataPoint {
122+ . collect_and_reset ( & mut s_data. data_points , |attributes, aggr| SumDataPoint {
121123 attributes,
122124 value : aggr. value . get_value ( ) ,
123125 exemplars : vec ! [ ] ,
Original file line number Diff line number Diff line change @@ -1460,14 +1460,12 @@ mod tests {
14601460 asynchronous_instruments_cumulative_data_points_only_from_last_measurement_helper (
14611461 "gauge" , true ,
14621462 ) ;
1463- // TODO fix: all asynchronous instruments should not emit data points if not measured
1464- // but these implementations are still buggy
14651463 asynchronous_instruments_cumulative_data_points_only_from_last_measurement_helper (
1466- "counter" , false ,
1464+ "counter" , true ,
14671465 ) ;
14681466 asynchronous_instruments_cumulative_data_points_only_from_last_measurement_helper (
14691467 "updown_counter" ,
1470- false ,
1468+ true ,
14711469 ) ;
14721470 }
14731471
Original file line number Diff line number Diff line change @@ -524,9 +524,8 @@ fn aggregate_fn<T: Number>(
524524 }
525525 Aggregation :: Sum => {
526526 let fns = match kind {
527- // TODO implement: observable instruments should not report data points on every collect
528- // from SDK: For asynchronous instruments with Delta or Cumulative aggregation temporality,
529- // MetricReader.Collect MUST only receive data points with measurements recorded since the previous collection
527+ // Observable instruments use collect_and_reset to report only data points
528+ // measured in the current callback, removing stale attributes
530529 InstrumentKind :: ObservableCounter => b. precomputed_sum ( true ) ,
531530 InstrumentKind :: ObservableUpDownCounter => b. precomputed_sum ( false ) ,
532531 InstrumentKind :: Counter | InstrumentKind :: Histogram => b. sum ( true ) ,
You can’t perform that action at this time.
0 commit comments