Skip to content

Align OTLP HTTP retry behaviour with the specification - #5460

Closed
henry3260 wants to merge 1 commit into
open-telemetry:mainfrom
henry3260:otlp-http-retry-spec
Closed

Align OTLP HTTP retry behaviour with the specification#5460
henry3260 wants to merge 1 commit into
open-telemetry:mainfrom
henry3260:otlp-http-retry-spec

Conversation

@henry3260

@henry3260 henry3260 commented Jul 25, 2026

Copy link
Copy Markdown

Description

Aligns the retry behaviour of the three OTLP HTTP exporters (traces, metrics, logs) in opentelemetry-exporter-otlp-proto-http with the OTLP specification:

  • Retryable status codes: the spec lists exactly 429, 502, 503 and 504 as retryable and requires all other 4xx/5xx codes not be retried. Previously _is_retryable treated 429 as permanent (dropping the batch immediately) while retrying 408 and every 5xx code.
  • Retry-After header: the spec asks clients to honour a Retry-After header on a retryable response, falling back to exponential backoff only when it is absent. Previously the backoff was computed before the request was sent, so the header could never influence the delay.

A new _extract_retry_after helper parses both RFC 7231 forms (delay-seconds and HTTP-date). An unparseable or non-finite value falls back to exponential backoff, and an already-elapsed delay retries immediately. A Retry-After longer than the remaining export deadline still ends the export, preserving the existing timeout contract.

The experimental opentelemetry-exporter-otlp-common shared client already implements these rules; this brings the stable HTTP exporters in line with it without sharing code between a stable and an experimental package.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Ran the full OTLP HTTP exporter test suite (97 tests passed), including new tests added in this PR:

  • tests/test_common.py: unit tests for _extract_retry_after — delay-seconds, negative delay clamped to zero, non-finite and malformed values falling back to backoff, HTTP-date in the future/past, and naive HTTP-date treated as UTC
  • tests/test_proto_span_exporter.py, tests/test_proto_log_exporter.py, tests/metrics/test_otlp_metrics_exporter.py: per-exporter tests that 429 is retried (test_too_many_requests_is_retried) and that a Retry-After header overrides the exponential backoff (test_retry_after_header_overrides_backoff)

@henry3260
henry3260 requested a review from a team as a code owner July 25, 2026 07:19
Per the OTLP spec, only 429, 502, 503 and 504 are retryable, and a
Retry-After header on such a response must be honoured, falling back to
exponential backoff only when it is absent.

The HTTP exporters did neither: 429 was dropped immediately while 408
and every 5xx code was retried, and the backoff was computed before the
request was sent, so Retry-After could never influence it.

Retry exactly the four spec-mandated codes and let a parseable
Retry-After value (delay-seconds or HTTP-date) override the backoff for
that attempt, matching the rules the experimental otlp-common client
already implements.
@henry3260
henry3260 force-pushed the otlp-http-retry-spec branch from ae2fe5c to bf6016f Compare July 25, 2026 07:19
@herin049

Copy link
Copy Markdown
Contributor

This is already being addressed in #5389

@henry3260

Copy link
Copy Markdown
Author

This is already being addressed in #5389

Thanks — I saw #5389. That's a larger refactor that fixes this incidentally via the shared otlp-common client. #5460 is a small, targeted fix for the stable otlp-proto-http package: today 429 is dropped instead of retried and Retry-After is ignored — a spec-compliance bug users hit right now, and it's easy to backport.
would it make sense to land this focused fix first, or would you prefer to wait for #5389? Happy to close if the refactor is close.

@herin049

Copy link
Copy Markdown
Contributor

This is already being addressed in #5389

Thanks — I saw #5389. That's a larger refactor that fixes this incidentally via the shared otlp-common client. #5460 is a small, targeted fix for the stable otlp-proto-http package: today 429 is dropped instead of retried and Retry-After is ignored — a spec-compliance bug users hit right now, and it's easy to backport. would it make sense to land this focused fix first, or would you prefer to wait for #5389? Happy to close if the refactor is close.

I'd prefer we just wait for #5389 since the changes in this targeted fix would end up being removed anyways once its merged (because of the larger refactor)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants