Skip to content

Commit

Permalink
chore: Add error logging for failed OpenTelemetry HTTP export (open-t…
Browse files Browse the repository at this point in the history
…elemetry#1498)

Co-authored-by: Lalit Kumar Bhasin <[email protected]>
Co-authored-by: Cijo Thomas <[email protected]>
  • Loading branch information
3 people authored Feb 1, 2024
1 parent 57c3aa3 commit d19187d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
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 @@ impl LogExporter for OtlpHttpClient {
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?;

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()));
}

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 @@ impl SpanExporter for OtlpHttpClient {
}

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

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()));
}

Ok(())
})
Expand Down

0 comments on commit d19187d

Please sign in to comment.