Skip to content

Metrics: Gauge (last-value) via LWWRegisterΒ #1202

Description

@keddie

πŸ€– This comment was generated by Claude on behalf of @keddie.

Part of #1201.

Gauge β€” last-value metric via LWWRegister

A gauge reports a current value (temperature, queue depth, in-use memory) β€” the thing a Sum can't express. The mergeable form is last-value-wins, which is exactly LWWRegister, already in the CRDT zoo. This is the cheapest primitive in the epic: merge by timestamp, done.

Shape

  • LWWRegister<Double> (or a numeric payload) per attribute set.
  • Merge = higher-timestamp wins (existing LWWRegister semantics).
  • Covers OTel Gauge / ObservableGauge (async observed current value).
  • Serializes to OTLP NumberDataPoint under a Gauge.

Notes / design surface

  • Tie-break must be deterministic β€” reuse whatever total order LWWRegister already uses (timestamp + replica-id tiebreak); don't introduce a second convention.
  • Async/observable gauges are pull-at-collection β€” the register just holds the latest observed value; no accumulation.
  • Confirm the injected Clock/timestamp source is the same one the rest of the exporter uses (time is a dependency β€” no wall-clock reads).

Acceptance

  • Gauge metric backed by LWWRegister, merge-by-timestamp.
  • OTLP Gauge/NumberDataPoint serialization.
  • Tests: set/observe/merge, last-writer-wins under concurrent updates, deterministic tie-break.

Placement (zoo vs. exporter-local) is resolved once for the epic β€” see #1201.

Metadata

Metadata

Assignees

No one assigned

    Labels

    readyClear acceptance criteria, ready to implement

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions