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

chore: Add error logging for failed OpenTelemetry HTTP export #1498

Merged
merged 14 commits into from
Feb 1, 2024
13 changes: 12 additions & 1 deletion opentelemetry-otlp/src/exporter/http/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,18 @@
request.headers_mut().insert(k.clone(), v.clone());
}

client.send(request).await?;
let request_uri = request.uri().to_string();
let response = client.send(request).await?;

Check warning on line 35 in opentelemetry-otlp/src/exporter/http/logs.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/http/logs.rs#L34-L35

Added lines #L34 - L35 were not covered by tests

if !response.status().is_success() {
let error = format!(
"OpenTelemetry logs export failed. Url: {}, Status Code: {}, Response: {:?}",
response.status().as_u16(),
request_uri,
response.body()
);
return Err(LogError::Other(error.into()));
}

Check warning on line 45 in opentelemetry-otlp/src/exporter/http/logs.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/http/logs.rs#L37-L45

Added lines #L37 - L45 were not covered by tests

Ok(())
}
Expand Down
13 changes: 12 additions & 1 deletion opentelemetry-otlp/src/exporter/http/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,18 @@
}

Box::pin(async move {
client.send(request).await?;
let request_uri = request.uri().to_string();
let response = client.send(request).await?;

Check warning on line 50 in opentelemetry-otlp/src/exporter/http/trace.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/http/trace.rs#L49-L50

Added lines #L49 - L50 were not covered by tests

if !response.status().is_success() {
let error = format!(
"OpenTelemetry trace export failed. Url: {}, Status Code: {}, Response: {:?}",
response.status().as_u16(),
request_uri,
response.body()
);
return Err(TraceError::Other(error.into()));
}

Check warning on line 60 in opentelemetry-otlp/src/exporter/http/trace.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/http/trace.rs#L52-L60

Added lines #L52 - L60 were not covered by tests

Ok(())
})
Expand Down
Loading