Skip to content

[feature request] Limit Maximum Retry Attempts #6282

Open
@nimanikoo

Description

@nimanikoo

Add support for limiting maximum retry attempts in TryGetRetryResult

While reviewing the retry mechanism implemented in TryGetRetryResult, I came across the following TODO:

// TODO: Consider introducing a fixed max number of retries (e.g. max 5 retries).

Currently, retries continue until the specified deadline is reached. While this follows the spec, it could introduce the following risks:

  • Unbounded retry loops
  • High memory or CPU usage in batch processors (due to prolonged delays)
  • Longer blocking operations in simple processors

I’d like to propose introducing a MaxAttempts threshold (e.g. 5 retries) as a safeguard against excessive retries.

If the team agrees with this direction, I can proceed with the implementation and submit a pull request.

https://github.com/open-telemetry/opentelemetry-dotnet/blob/8c1e63894f0286b1c48b0448a866fdb3bd603fe8/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ExportClient/OtlpRetry.cs

What is the expected behavior?

The retry mechanism will stop after a predefined maximum number of retries (e.g., 5 attempts).

If the maximum retry attempts are reached, the operation will fail without exceeding the deadline, preventing unbounded retries.

Which alternative solutions or features have you considered?

fix

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions