Skip to content

update_aggregator

Aggregate possibly noisy or high-frequency updates.

Some update types might be high-frequency, or might be noisy. This module provides functions to aggregate such updates, e.g. by computing the median of multiple measurements between the same clocks.

This effectively reduces update frequency and noise, at the cost of delayed reaction time to diagnostic state changes.

Functions:

aggregate_clock_diff_measurements

aggregate_clock_diff_measurements(
    updates: Iterable[GraphUpdate],
) -> list[GraphUpdate]

Aggregate ClockDiffMeasurements by grouping them by (src, dst) pairs.

For each group, compute the median diff_ns and create a single aggregated measurement. All measurements in the group are removed from the iterable and replaced with the single aggregated one.

Parameters:

  • updates (Iterable[GraphUpdate]) –

    An iterable of GraphUpdate messages (not limited to ClockDiffMeasurements).

Returns:

  • list[GraphUpdate]

    The updates iterable with all ClockDiffMeasurements grouped by (src, dst) and replaced

  • list[GraphUpdate]

    with a single aggregated measurement for each group.

  • list[GraphUpdate]

    Non-measurement updates are preserved as-is.