Skip to content

Commit

Permalink
fix: Remove full url from default span & http.url -> url.full in …
Browse files Browse the repository at this point in the history
…`SpanBackendWithUrl`
  • Loading branch information
eopb committed Apr 10, 2024
1 parent d401fc5 commit d2286b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions reqwest-tracing/src/reqwest_otel_span_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub fn default_span_name<'a>(req: &'a Request, ext: &'a Extensions) -> Cow<'a, s
}

/// The default [`ReqwestOtelSpanBackend`] for [`TracingMiddleware`]. Note that it doesn't include
/// the `http.url` field in spans, you can use [`SpanBackendWithUrl`] to add it.
/// the `url.full` field in spans, you can use [`SpanBackendWithUrl`] to add it.
///
/// [`TracingMiddleware`]: crate::middleware::TracingMiddleware
pub struct DefaultSpanBackend;
Expand All @@ -119,15 +119,15 @@ impl ReqwestOtelSpanBackend for DefaultSpanBackend {
}
}

/// Similar to [`DefaultSpanBackend`] but also adds the `http.url` attribute to request spans.
/// Similar to [`DefaultSpanBackend`] but also adds the `url.full` attribute to request spans.
///
/// [`TracingMiddleware`]: crate::middleware::TracingMiddleware
pub struct SpanBackendWithUrl;

impl ReqwestOtelSpanBackend for SpanBackendWithUrl {
fn on_request_start(req: &Request, ext: &mut Extensions) -> Span {
let name = default_span_name(req, ext);
reqwest_otel_span!(name = name, req, http.url = %remove_credentials(req.url()))
reqwest_otel_span!(name = name, req, url.full = %remove_credentials(req.url()))
}

fn on_request_end(span: &Span, outcome: &Result<Response>, _: &mut Extensions) {
Expand Down
4 changes: 1 addition & 3 deletions reqwest-tracing/src/reqwest_otel_span_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
/// - url.scheme
/// - server.address
/// - server.port
/// - url.full
/// - otel.kind
/// - otel.name
/// - otel.status_code
Expand Down Expand Up @@ -54,7 +53,7 @@
///
/// If nothing else is specified, the span generated by `reqwest_otel_span!` is identical to the one you'd
/// get by using [`DefaultSpanBackend`]. Note that to avoid leaking sensitive information, the
/// macro doesn't include `http.url`, even though it's required by opentelemetry. You can add the
/// macro doesn't include `url.full`, even though it's required by opentelemetry. You can add the
/// URL attribute explicitly by using [`SpanBackendWithUrl`] instead of `DefaultSpanBackend` or
/// adding the field on your own implementation.
///
Expand Down Expand Up @@ -137,7 +136,6 @@ macro_rules! reqwest_otel_span {
url.scheme = %scheme,
server.address = %host,
server.port = %host_port,
url.full = %url,
user_agent.original = %user_agent,
otel.kind = "client",
otel.name = %otel_name,
Expand Down

0 comments on commit d2286b5

Please sign in to comment.