Skip to content

otlptranslator: Error silently swallowed in addSumNumberDataPoints #17953

@aknuds1

Description

@aknuds1

Bug Description

In storage/remote/otlptranslator/prometheusremotewrite/number_data_points.go, the addSumNumberDataPoints function silently swallows errors from createAttributes:

lbls, err := c.createAttributes(
    pt.Attributes(),
    settings,
    nil,
    true,
    meta,
    model.MetricNameLabel,
    meta.MetricFamilyName,
)
if err != nil {
    return nil  // BUG: should be "return err"
}

https://github.com/prometheus/prometheus/blob/main/storage/remote/otlptranslator/prometheusremotewrite/number_data_points.go#L88-L89

Compare with addGaugeNumberDataPoints in the same file which correctly returns the error:

if err != nil {
    return err
}

https://github.com/prometheus/prometheus/blob/main/storage/remote/otlptranslator/prometheusremotewrite/number_data_points.go#L47-L48

Impact

When createAttributes fails for sum metrics, the error is silently discarded and processing continues. This could lead to:

  • Silent data loss (sum metrics not being written)
  • Difficult-to-debug issues in OTLP ingestion pipelines

Root Cause

The bug was introduced in #16951 during a refactor. The original code had return err, but it was accidentally changed to return nil.

Suggested Fix

 if err != nil {
-    return nil
+    return err
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions