Capture URL as http.url (#64)
parent
7a09e335aa
commit
920cb5ac16
|
@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
- HTTP URL is captured in traces as the `http.url` attribute.
|
||||
|
||||
## [0.3.1] - 2022-09-21
|
||||
- Added support for `opentelemetry` version `0.18`.
|
||||
|
|
|
@ -51,8 +51,8 @@ pub use middleware::TracingMiddleware;
|
|||
pub use reqwest_otel_span_builder::{
|
||||
default_on_request_end, default_on_request_failure, default_on_request_success,
|
||||
DefaultSpanBackend, ReqwestOtelSpanBackend, ERROR_CAUSE_CHAIN, ERROR_MESSAGE, HTTP_HOST,
|
||||
HTTP_METHOD, HTTP_SCHEME, HTTP_STATUS_CODE, HTTP_USER_AGENT, NET_HOST_PORT, OTEL_KIND,
|
||||
OTEL_NAME, OTEL_STATUS_CODE,
|
||||
HTTP_METHOD, HTTP_SCHEME, HTTP_STATUS_CODE, HTTP_URL, HTTP_USER_AGENT, NET_HOST_PORT,
|
||||
OTEL_KIND, OTEL_NAME, OTEL_STATUS_CODE,
|
||||
};
|
||||
|
||||
#[doc(hidden)]
|
||||
|
|
|
@ -12,14 +12,16 @@ pub const HTTP_METHOD: &str = "http.method";
|
|||
pub const HTTP_SCHEME: &str = "http.scheme";
|
||||
/// The `http.host` field added to the span by [`reqwest_otel_span`]
|
||||
pub const HTTP_HOST: &str = "http.host";
|
||||
/// The `http.url` field added to the span by [`reqwest_otel_span`]
|
||||
pub const HTTP_URL: &str = "http.url";
|
||||
/// The `host.port` field added to the span by [`reqwest_otel_span`]
|
||||
pub const NET_HOST_PORT: &str = "net.host.port";
|
||||
/// The `otel.kind` field added to the span by [`reqwest_otel_span`]
|
||||
pub const OTEL_KIND: &str = "otel.kind";
|
||||
/// The `otel.name` field added to the span by [`reqwest_otel_span`]
|
||||
pub const OTEL_NAME: &str = "otel.name";
|
||||
/// The `otel.status.code` field added to the span by [`reqwest_otel_span`]
|
||||
pub const OTEL_STATUS_CODE: &str = "otel.status_code";
|
||||
/// The `otel.status_code.code` field added to the span by [`reqwest_otel_span`]
|
||||
pub const OTEL_STATUS_CODE: &str = "http.status_code";
|
||||
/// The `error.message` field added to the span by [`reqwest_otel_span`]
|
||||
pub const ERROR_MESSAGE: &str = "error.message";
|
||||
/// The `error.cause_chain` field added to the span by [`reqwest_otel_span`]
|
||||
|
|
|
@ -114,10 +114,11 @@ macro_rules! reqwest_otel_span {
|
|||
(level=$level:expr, $request:ident, $($field:tt)*) => {
|
||||
{
|
||||
let method = $request.method();
|
||||
let scheme = $request.url().scheme();
|
||||
let host = $request.url().host_str().unwrap_or("");
|
||||
let host_port = $request.url().port().unwrap_or(0) as i64;
|
||||
let path = $request.url().path();
|
||||
let url = $request.url();
|
||||
let scheme = url.scheme();
|
||||
let host = url.host_str().unwrap_or("");
|
||||
let host_port = url.port().unwrap_or(0) as i64;
|
||||
let path = url.path();
|
||||
let otel_name = format!("{} {}", method, path);
|
||||
|
||||
macro_rules! request_span {
|
||||
|
@ -128,6 +129,7 @@ macro_rules! reqwest_otel_span {
|
|||
http.method = %method,
|
||||
http.scheme = %scheme,
|
||||
http.host = %host,
|
||||
http.url = %url,
|
||||
net.host.port = %host_port,
|
||||
otel.kind = "client",
|
||||
otel.name = %otel_name,
|
||||
|
|
Loading…
Reference in New Issue