Otel.Metrics.Aggregation.Sum (otel v0.4.1)

Copy Markdown View Source

Sum aggregation. Collects the arithmetic sum of measurements.

Stores integer and float components separately for atomic updates. ETS entry format: {key, int_value, float_value, start_time, reservoir_state}.

The fifth slot holds the exemplar reservoir state (Otel.Metrics.Exemplar.Reservoir.SimpleFixedSize). Reservoir state lives alongside the aggregation cell so a single ETS row carries everything collect/3 needs to emit a datapoint with exemplars — there is no separate ExemplarsStorage table.

Cumulative-only — collect/3 returns the running total since stream start. Delta temporality is not supported (minikube hardcodes cumulative; spec metrics/sdk.md L1290-L1297 default).

Summary

Functions

aggregate(metrics_tab, key, value, opts)

@spec aggregate(
  metrics_tab :: :ets.table(),
  key :: term(),
  value :: number(),
  opts :: map()
) :: :ok

collect(metrics_tab, stream_name, opts)

@spec collect(
  metrics_tab :: :ets.table(),
  stream_key :: String.t(),
  opts :: map()
) :: [Otel.Metrics.Aggregation.datapoint()]

offer_exemplar(metrics_tab, key, value, time, filtered_attrs, ctx)

@spec offer_exemplar(
  metrics_tab :: :ets.table(),
  key :: term(),
  value :: number(),
  time :: non_neg_integer(),
  filtered_attrs :: %{required(String.t()) => term()},
  ctx :: Otel.Ctx.t()
) :: :ok