Fix main builds (#66)

* Remove unneeded derefs

* Resolve reqwest_otel_span correctly in docs.

Macros always resolve to the crate root.
tower
Robert Collins 2022-11-07 09:39:03 +01:00 committed by GitHub
parent ddd7e12104
commit 7a09e335aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View File

@ -59,10 +59,10 @@ pub fn default_on_request_success(span: &Span, response: &Response) {
let status_code = response.status().as_u16() as i64;
let user_agent = get_header_value("user_agent", response.headers());
if let Some(span_status) = span_status {
span.record(OTEL_STATUS_CODE, &span_status);
span.record(OTEL_STATUS_CODE, span_status);
}
span.record(HTTP_STATUS_CODE, &status_code);
span.record(HTTP_USER_AGENT, &user_agent.as_str());
span.record(HTTP_STATUS_CODE, status_code);
span.record(HTTP_USER_AGENT, user_agent.as_str());
}
/// Populates default failure fields for a given [`reqwest_otel_span!`] span.
@ -70,13 +70,13 @@ pub fn default_on_request_success(span: &Span, response: &Response) {
pub fn default_on_request_failure(span: &Span, e: &Error) {
let error_message = e.to_string();
let error_cause_chain = format!("{:?}", e);
span.record(OTEL_STATUS_CODE, &"ERROR");
span.record(ERROR_MESSAGE, &error_message.as_str());
span.record(ERROR_CAUSE_CHAIN, &error_cause_chain.as_str());
span.record(OTEL_STATUS_CODE, "ERROR");
span.record(ERROR_MESSAGE, error_message.as_str());
span.record(ERROR_CAUSE_CHAIN, error_cause_chain.as_str());
if let Error::Reqwest(e) = e {
span.record(
HTTP_STATUS_CODE,
&e.status()
e.status()
.map(|s| s.to_string())
.unwrap_or_else(|| "".to_string())
.as_str(),

View File

@ -1,5 +1,5 @@
#[macro_export]
/// [`reqwest_otel_span!`] creates a new [`tracing::Span`].
/// [`reqwest_otel_span!`](crate::reqwest_otel_span) creates a new [`tracing::Span`].
/// It empowers you to add custom properties to the span on top of the default properties provided by the macro
///
/// Default Fields:
@ -26,7 +26,7 @@
///
/// # Macro syntax
///
/// The first argument passed to [`reqwest_otel_span!`] is a reference to an [`reqwest::Request`].
/// The first argument passed to [`reqwest_otel_span!`](crate::reqwest_otel_span) is a reference to an [`reqwest::Request`].
///
/// ```rust
/// use reqwest_middleware::Result;