Skip to content

Commit

Permalink
no allocation in release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mustakimali committed Jan 29, 2024
1 parent b6e30b9 commit 87d021a
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions opentelemetry-otlp/src/exporter/http/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,25 @@ impl SpanExporter for OtlpHttpClient {
}

Box::pin(async move {
#[cfg(debug_assertions)]
let request_uri = request.uri().to_string();
let response = client.send(request).await?;
#[cfg(not(debug_assertions))]
client.send(request).await?;

if response.status().is_success() {
Ok(())
} else {
#[cfg(debug_assertions)]
let request_uri = request_uri.as_str();
#[cfg(not(debug_assertions))]
const request_uri: &str = "(available in debug mode)";
#[cfg(debug_assertions)]
{
let request_uri = request.uri().to_string();
let response = client.send(request).await?;

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

Ok(())
})
}

Expand Down

0 comments on commit 87d021a

Please sign in to comment.