Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Retry to OTLP Exporter #2727

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

AaronRM
Copy link

@AaronRM AaronRM commented Feb 27, 2025

Fixes #
Design discussion issue (if applicable) #

Changes

Please provide a brief description of the changes here.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@AaronRM AaronRM changed the title Aaronm retry Add Retry to OTLP Exporter Feb 27, 2025
Copy link

codecov bot commented Feb 27, 2025

Codecov Report

Attention: Patch coverage is 73.97260% with 38 lines in your changes missing coverage. Please review.

Project coverage is 79.3%. Comparing base (367e484) to head (98469f3).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
opentelemetry-otlp/src/exporter/tonic/logs.rs 0.0% 37 Missing ⚠️
opentelemetry-otlp/src/exporter/http/mod.rs 0.0% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main   #2727    +/-   ##
======================================
  Coverage   79.3%   79.3%            
======================================
  Files        123     124     +1     
  Lines      22670   22800   +130     
======================================
+ Hits       17986   18093   +107     
- Misses      4684    4707    +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

use std::future::Future;
use std::time::{Duration, SystemTime};
use opentelemetry::otel_warn;
use tokio::time::sleep;
Copy link
Member

@lalitb lalitb Feb 28, 2025

Choose a reason for hiding this comment

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

tokio runtime won't be available here. Should we move this code under exporter/tonic, or if we want to keep it generic, one option could be to make the delay function configurable as an argument to retry_with_exponential_backoff - such that retry function can be callable from both async and blocking code.

Copy link
Author

Choose a reason for hiding this comment

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

The idea was the retry logic should be generic and used across all the OTLP exporters. Going to try that approach first and try to avoid the direct tokio dependency.

Err(err) if attempt < policy.max_retries => {
attempt += 1;
// Log the error and retry after a delay with jitter
otel_warn!(name: "OtlpRetry", message = format!("Retrying operation {:?} due to error: {:?}", operation_name, err));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
otel_warn!(name: "OtlpRetry", message = format!("Retrying operation {:?} due to error: {:?}", operation_name, err));
otel_debug!(name: "OtlpRetry", message = format!("Retrying operation {:?} due to error: {:?}", operation_name, err));

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