Skip to content

otlp: drop metrics with unsupported temporality instead of rejecting the request - #20536

Merged
aknuds1 merged 1 commit into
prometheus:mainfrom
r0h1tb:fix/otlp-drop-invalid-temporality
Nov 23, 2026
Merged

aknuds1 merged 1 commit into
prometheus:mainfrom
r0h1tb:fix/otlp-drop-invalid-temporality

Conversation

@r0h1tb

@r0h1tb r0h1tb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Which issue(s) does the PR fix:

No issue filed. Same regression as #19338, with a different trigger.

Since #16951 (v3.7.0), ConsumeMetrics rolls back the whole OTLP request when FromMetrics returns an error, and the handler answers 500. A delta metric sent without otlp-native-delta-ingestion (or otlp-deltatocumulative) is such an error, so one delta metric in a request drops every other metric in it:

request: Sum "good" (cumulative) + Sum "bad" (delta), default flags
main:    500 invalid temporality and type combination for metric "bad", nothing stored
v3.6:    good_total stored, the error logged

docs/feature_flags.md describes delta metrics as dropped without the flag, and TestTemporality already expects test_metric_1 to be appended in "delta rejected when not allowed". The test commits the appender even when FromMetrics returns an error, so it did not catch this. Mixed requests are common: SDKs configured to prefer delta, or a collector batching metrics from several services.

This reports the unsupported temporality as a warning instead of an error, the way #19343 handled metrics with no data points, so only that metric is dropped. The warning is counted in prometheus_api_otlp_translation_warnings_total{category="invalid_temporality"}.

Tests: TestTemporality now checks the warnings, and its 5 invalid-temporality cases expect a warning instead of an error. In TestOTLPWriteHandler the "empty metric does not reject healthy metrics" case is now a table with an empty-data-points case and a delta case, and "translation warnings metric" has an invalid_temporality case. Without the change the handler test gets 500 instead of 200. I also checked it through NewOTLPWriteHandler into a real TSDB: nothing stored before, good_total stored after.

Other errors from FromMetrics still roll back the request, for example an exponential histogram with scale below -4 or a metric with no type. I left those alone to keep this focused. I can convert them here too if you prefer.

Release notes for end users (ALL commits must be considered).

Reviewers should verify clarity and quality.

[BUGFIX] OTLP: Do not abort an entire OTLP payload ingestion if one metric has an unsupported temporality, such as delta without native delta ingestion. Regression in v3.7.0.

…the request

Since prometheus#16951 (v3.7.0) any error from FromMetrics rolls back the whole OTLP
request and answers 500. A delta metric sent without native delta ingestion
returned such an error, so one delta metric dropped every other metric in
the same request. Before v3.7.0 the error was only logged and the rest was
written.

Report the unsupported temporality as a warning, like prometheus#19343 did for
metrics with no data points, so only that metric is dropped. It is counted
in prometheus_api_otlp_translation_warnings_total{category="invalid_temporality"}.

Signed-off-by: Rohit Behera <126186063+r0h1tb@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the change to skip unsupported-temporality metrics without rejecting healthy metrics in the same request.

No open issues 🎉

What changed in this PR

Fixes an OTLP ingestion regression by dropping metrics with unsupported temporality without rejecting healthy metrics in the same request. This follows the warning-based handling already used for metrics with no data points.

Changes:

  • Reports unsupported temporality as a categorized warning instead of a request-fatal error.
  • Adds the invalid_temporality warning category for translation monitoring.
  • Updates translator and handler tests to cover warnings and successful ingestion of mixed payloads.
File Description
storage/​remote/​write_otlp_handler_test.go Tests warning counts and preservation of healthy metrics alongside dropped metrics.
storage/​remote/​otlptranslator/​prometheusremotewrite/​metrics_to_prw.go Emits a warning and skips metrics with unsupported temporality.
storage/​remote/​otlptranslator/​prometheusremotewrite/​metrics_to_prw_test.go Updates temporality cases to expect warnings rather than errors.
storage/​remote/​otlptranslator/​prometheusremotewrite/​annotations.go Defines and documents the invalid_temporality warning category.

Review effort: Balanced

@aknuds1 aknuds1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and thanks!

@aknuds1
aknuds1 merged commit ae44e72 into prometheus:main Nov 23, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants