Skip to content

PrecomputedSum in Delta temporality resets baseline on missed/rejected observations, double-counting values #3714

Open

Description

@darkraider01

What happened?

In PrecomputedSum::delta, collection drains and resets the value_map. Any attribute set that is not observed in the current cycle (e.g. an async callback temporarily misses an observation, errors, or an invalid measurement like NaN is dropped) is omitted from new_reported.
When *reported = new_reported executes, all unobserved baselines are cleared.
When the instrument subsequently observes a new measurement, reported.get(...) returns None and defaults to 0. This causes the delta to be computed against 0 rather than the last valid baseline, re-counting previously exported values.

Reproduction:

  1. Cycle 1: Observe 100 -> Collect: exports delta 100 (baseline cached as 100).
  2. Cycle 2: Missed observation (or dropped NaN) -> Collect: exports nothing, but clears reported.
  3. Cycle 3: Observe 110 -> Collect: exports delta 110 (110 - 0) instead of 10 (110 - 100), double-counting the initial 100.

What did you expect to happen?

Missed or rejected observations should not immediately discard the baseline. The next valid observation should compute the delta relative to the last reported value.

OpenTelemetry API Version (i.e version of opentelemetry crate)

0.32.0 (and main)

OpenTelemetry SDK Version (i.e version of opentelemetry_sdk crate)

0.32.1 (and main)

What Exporter(s) are you seeing the problem on?

No response

Relevant log output

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Activity

  1. darkraider01 commented on Sep 7, 2026

    @darkraider01
    MemberAuthor

    Considerations:
    Simply retaining all unobserved entries in reported would cause memory to grow indefinitely for short-lived/ephemeral attributes. A proper fix will likely need a stale-attribute eviction mechanism (e.g. TTL or max missed collection cycles) to safely prune dead attribute sets while tolerating transient gaps.

  2. scottgerring commented on Sep 14, 2026

    @scottgerring
    Member

    Hey @darkraider01 thanks for raising this!
    It looks like this is blocked on a spec clarification issue - namely open-telemetry/opentelemetry-specification#4861

    I suggest we hold this open to track until that is resolved

    /cc @cijothomas

  3. added
    S-blocked-specStatus: Blocked on open or unresolved spec
    enhancementNew feature or request
    and removed
    bugSomething isn't working
    on Sep 14, 2026
  4. changed the title [-][Bug]: PrecomputedSum in Delta temporality resets baseline on missed/rejected observations, double-counting values[/-] [+] PrecomputedSum in Delta temporality resets baseline on missed/rejected observations, double-counting values[/+] on Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-blocked-specStatus: Blocked on open or unresolved specenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions