Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
# Fail the build if there are warnings
RUSTFLAGS: "-D warnings"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
Expand Down Expand Up @@ -56,10 +56,10 @@ jobs:
- opentelemetry_0_18
- opentelemetry_0_19
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Cache dependencies
id: cache-dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
Expand All @@ -80,7 +80,7 @@ jobs:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
Expand All @@ -95,7 +95,7 @@ jobs:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
Expand Down
8 changes: 4 additions & 4 deletions src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use tracing::Span;
///
/// # Usage
///
/// Register `TracingLogger` as a middleware for your application using `.wrap` on `App`.
/// Register `TracingLogger` as a middleware for your application using `.wrap` on `App`.
/// In this example we add a [`tracing::Subscriber`] to output structured logs to the console.
///
/// ```rust
Expand Down Expand Up @@ -119,7 +119,7 @@ where
fn new_transform(&self, service: S) -> Self::Future {
ready(Ok(TracingLoggerMiddleware {
service,
root_span_builder: std::marker::PhantomData::default(),
root_span_builder: std::marker::PhantomData,
}))
}
}
Expand Down Expand Up @@ -240,12 +240,12 @@ fn emit_event_on_error<B: 'static>(outcome: &Result<ServiceResponse<B>, actix_we
Ok(response) => {
if let Some(err) = response.response().error() {
// use the status code already constructed for the outgoing HTTP response
emit_error_event(err.as_response_error(), response.status())
emit_error_event(err.as_response_error(), response.status());
}
}
Err(error) => {
let response_error = error.as_response_error();
emit_error_event(response_error, response_error.status_code())
emit_error_event(response_error, response_error.status_code());
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/root_span_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ macro_rules! root_span {
.get("User-Agent")
.map(|h| h.to_str().unwrap_or(""))
.unwrap_or("");
let referer = $request
.headers()
.get("Referer")
.map(|h| h.to_str().unwrap_or(""))
.unwrap_or("");
let http_route: std::borrow::Cow<'static, str> = $request
.match_pattern()
.map(Into::into)
Expand All @@ -101,6 +106,7 @@ macro_rules! root_span {
http.host = %connection_info.host(),
http.client_ip = %$request.connection_info().realip_remote_addr().unwrap_or(""),
http.user_agent = %user_agent,
http.referer = %referer,
http.target = %$request.uri().path_and_query().map(|p| p.as_str()).unwrap_or(""),
http.status_code = $crate::root_span_macro::private::tracing::field::Empty,
otel.name = %format!("HTTP {} {}", http_method, http_route),
Expand Down Expand Up @@ -216,6 +222,6 @@ pub mod private {
pub fn get_request_id(request: &ServiceRequest) -> RequestId {
use actix_web::HttpMessage;

request.extensions().get::<RequestId>().cloned().unwrap()
request.extensions().get::<RequestId>().copied().unwrap()
}
}