Skip to content

Commit

Permalink
Fix applying exemplar filter to observable instruments
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed Nov 6, 2024
1 parent d5aea0f commit edbcea7
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,17 @@ def __init__(
] = []

def consume_measurement(self, measurement: Measurement) -> None:
should_sample_exemplar = (
self._sdk_config.exemplar_filter.should_sample(
measurement.value,
measurement.time_unix_nano,
measurement.attributes,
measurement.context,
),
)
for reader_storage in self._reader_storages.values():
reader_storage.consume_measurement(
measurement,
self._sdk_config.exemplar_filter.should_sample(
measurement.value,
measurement.time_unix_nano,
measurement.attributes,
measurement.context,
),
measurement, should_sample_exemplar
)

def register_asynchronous_instrument(
Expand Down Expand Up @@ -126,7 +128,15 @@ def collect(
)

for measurement in measurements:
metric_reader_storage.consume_measurement(measurement)
should_sample_exemplar = (
self._sdk_config.exemplar_filter.should_sample(
measurement.value,
measurement.time_unix_nano,
measurement.attributes,
measurement.context,
),
)
metric_reader_storage.consume_measurement(measurement, should_sample_exemplar)

result = self._reader_storages[metric_reader].collect()

Expand Down

0 comments on commit edbcea7

Please sign in to comment.