mirror of
https://github.com/TrueLayer/reqwest-middleware.git
synced 2024-12-26 10:56:32 +00:00
parent
af1080f21c
commit
385314a298
3 changed files with 12 additions and 12 deletions
|
@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.4.3] - 2023-05-15
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fix span and http status codes
|
||||||
|
|
||||||
## [0.4.2] - 2023-05-12
|
## [0.4.2] - 2023-05-12
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "reqwest-tracing"
|
name = "reqwest-tracing"
|
||||||
version = "0.4.2"
|
version = "0.4.3"
|
||||||
authors = ["Rodrigo Gryzinski <rodrigo.gryzinski@truelayer.com>"]
|
authors = ["Rodrigo Gryzinski <rodrigo.gryzinski@truelayer.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Opentracing middleware for reqwest."
|
description = "Opentracing middleware for reqwest."
|
||||||
|
|
|
@ -23,8 +23,8 @@ pub const NET_HOST_PORT: &str = "net.host.port";
|
||||||
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.code` field added to the span by [`reqwest_otel_span`]
|
/// The `otel.status_code` field added to the span by [`reqwest_otel_span`]
|
||||||
pub const OTEL_STATUS_CODE: &str = "http.status_code";
|
pub const OTEL_STATUS_CODE: &str = "otel.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`]
|
||||||
|
@ -61,12 +61,11 @@ pub fn default_on_request_end(span: &Span, outcome: &Result<Response>) {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn default_on_request_success(span: &Span, response: &Response) {
|
pub fn default_on_request_success(span: &Span, response: &Response) {
|
||||||
let span_status = get_span_status(response.status());
|
let span_status = get_span_status(response.status());
|
||||||
let status_code = response.status().as_u16() as i64;
|
|
||||||
let user_agent = get_header_value("user_agent", response.headers());
|
let user_agent = get_header_value("user_agent", response.headers());
|
||||||
if let Some(span_status) = span_status {
|
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_STATUS_CODE, response.status().as_u16());
|
||||||
span.record(HTTP_USER_AGENT, user_agent.as_str());
|
span.record(HTTP_USER_AGENT, user_agent.as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,13 +78,9 @@ pub fn default_on_request_failure(span: &Span, e: &Error) {
|
||||||
span.record(ERROR_MESSAGE, error_message.as_str());
|
span.record(ERROR_MESSAGE, error_message.as_str());
|
||||||
span.record(ERROR_CAUSE_CHAIN, error_cause_chain.as_str());
|
span.record(ERROR_CAUSE_CHAIN, error_cause_chain.as_str());
|
||||||
if let Error::Reqwest(e) = e {
|
if let Error::Reqwest(e) = e {
|
||||||
span.record(
|
if let Some(status) = e.status() {
|
||||||
HTTP_STATUS_CODE,
|
span.record(HTTP_STATUS_CODE, status.as_u16());
|
||||||
e.status()
|
}
|
||||||
.map(|s| s.to_string())
|
|
||||||
.unwrap_or_else(|| "".to_string())
|
|
||||||
.as_str(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue