mirror of
https://github.com/TrueLayer/reqwest-middleware.git
synced 2024-12-26 10:56:32 +00:00
Capture URL as http.url (#64)
This commit is contained in:
parent
7a09e335aa
commit
920cb5ac16
4 changed files with 13 additions and 8 deletions
|
@ -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).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
- HTTP URL is captured in traces as the `http.url` attribute.
|
||||||
|
|
||||||
## [0.3.1] - 2022-09-21
|
## [0.3.1] - 2022-09-21
|
||||||
- Added support for `opentelemetry` version `0.18`.
|
- Added support for `opentelemetry` version `0.18`.
|
||||||
|
|
|
@ -51,8 +51,8 @@ pub use middleware::TracingMiddleware;
|
||||||
pub use reqwest_otel_span_builder::{
|
pub use reqwest_otel_span_builder::{
|
||||||
default_on_request_end, default_on_request_failure, default_on_request_success,
|
default_on_request_end, default_on_request_failure, default_on_request_success,
|
||||||
DefaultSpanBackend, ReqwestOtelSpanBackend, ERROR_CAUSE_CHAIN, ERROR_MESSAGE, HTTP_HOST,
|
DefaultSpanBackend, ReqwestOtelSpanBackend, ERROR_CAUSE_CHAIN, ERROR_MESSAGE, HTTP_HOST,
|
||||||
HTTP_METHOD, HTTP_SCHEME, HTTP_STATUS_CODE, HTTP_USER_AGENT, NET_HOST_PORT, OTEL_KIND,
|
HTTP_METHOD, HTTP_SCHEME, HTTP_STATUS_CODE, HTTP_URL, HTTP_USER_AGENT, NET_HOST_PORT,
|
||||||
OTEL_NAME, OTEL_STATUS_CODE,
|
OTEL_KIND, OTEL_NAME, OTEL_STATUS_CODE,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
|
|
@ -12,14 +12,16 @@ pub const HTTP_METHOD: &str = "http.method";
|
||||||
pub const HTTP_SCHEME: &str = "http.scheme";
|
pub const HTTP_SCHEME: &str = "http.scheme";
|
||||||
/// The `http.host` field added to the span by [`reqwest_otel_span`]
|
/// The `http.host` field added to the span by [`reqwest_otel_span`]
|
||||||
pub const HTTP_HOST: &str = "http.host";
|
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`]
|
/// The `host.port` field added to the span by [`reqwest_otel_span`]
|
||||||
pub const NET_HOST_PORT: &str = "net.host.port";
|
pub const NET_HOST_PORT: &str = "net.host.port";
|
||||||
/// The `otel.kind` field added to the span by [`reqwest_otel_span`]
|
/// The `otel.kind` field added to the span by [`reqwest_otel_span`]
|
||||||
pub const OTEL_KIND: &str = "otel.kind";
|
pub const OTEL_KIND: &str = "otel.kind";
|
||||||
/// The `otel.name` field added to the span by [`reqwest_otel_span`]
|
/// The `otel.name` field added to the span by [`reqwest_otel_span`]
|
||||||
pub const OTEL_NAME: &str = "otel.name";
|
pub const OTEL_NAME: &str = "otel.name";
|
||||||
/// The `otel.status.code` field added to the span by [`reqwest_otel_span`]
|
/// The `otel.status_code.code` field added to the span by [`reqwest_otel_span`]
|
||||||
pub const OTEL_STATUS_CODE: &str = "otel.status_code";
|
pub const OTEL_STATUS_CODE: &str = "http.status_code";
|
||||||
/// The `error.message` field added to the span by [`reqwest_otel_span`]
|
/// The `error.message` field added to the span by [`reqwest_otel_span`]
|
||||||
pub const ERROR_MESSAGE: &str = "error.message";
|
pub const ERROR_MESSAGE: &str = "error.message";
|
||||||
/// The `error.cause_chain` field added to the span by [`reqwest_otel_span`]
|
/// 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)*) => {
|
(level=$level:expr, $request:ident, $($field:tt)*) => {
|
||||||
{
|
{
|
||||||
let method = $request.method();
|
let method = $request.method();
|
||||||
let scheme = $request.url().scheme();
|
let url = $request.url();
|
||||||
let host = $request.url().host_str().unwrap_or("");
|
let scheme = url.scheme();
|
||||||
let host_port = $request.url().port().unwrap_or(0) as i64;
|
let host = url.host_str().unwrap_or("");
|
||||||
let path = $request.url().path();
|
let host_port = url.port().unwrap_or(0) as i64;
|
||||||
|
let path = url.path();
|
||||||
let otel_name = format!("{} {}", method, path);
|
let otel_name = format!("{} {}", method, path);
|
||||||
|
|
||||||
macro_rules! request_span {
|
macro_rules! request_span {
|
||||||
|
@ -128,6 +129,7 @@ macro_rules! reqwest_otel_span {
|
||||||
http.method = %method,
|
http.method = %method,
|
||||||
http.scheme = %scheme,
|
http.scheme = %scheme,
|
||||||
http.host = %host,
|
http.host = %host,
|
||||||
|
http.url = %url,
|
||||||
net.host.port = %host_port,
|
net.host.port = %host_port,
|
||||||
otel.kind = "client",
|
otel.kind = "client",
|
||||||
otel.name = %otel_name,
|
otel.name = %otel_name,
|
||||||
|
|
Loading…
Reference in a new issue