From 70e8f75e8fc6b3dbe803e78bdd5a737f044522eb Mon Sep 17 00:00:00 2001 From: Luca Palmieri <20745048+LukeMathWalker@users.noreply.github.com> Date: Sun, 29 Sep 2024 10:25:03 +0200 Subject: [PATCH] Formatting --- .../examples/custom-root-span/src/main.rs | 15 +++++++------ .../examples/opentelemetry/src/main.rs | 7 +++--- .../request-id-response-header/src/main.rs | 3 ++- tracing-actix-web/src/middleware.rs | 22 ++++++++++++------- tracing-actix-web/src/otel.rs | 5 +---- tracing-actix-web/src/request_id.rs | 4 ++-- tracing-actix-web/src/root_span.rs | 4 ++-- tracing-actix-web/src/root_span_builder.rs | 13 ++++++----- tracing-actix-web/src/root_span_macro.rs | 9 +++++--- 9 files changed, 46 insertions(+), 36 deletions(-) diff --git a/tracing-actix-web/examples/custom-root-span/src/main.rs b/tracing-actix-web/examples/custom-root-span/src/main.rs index 17179accf..05a77c0dc 100644 --- a/tracing-actix-web/examples/custom-root-span/src/main.rs +++ b/tracing-actix-web/examples/custom-root-span/src/main.rs @@ -1,15 +1,16 @@ -use actix_web::body::MessageBody; -use actix_web::dev::{ServiceRequest, ServiceResponse}; -use actix_web::{web, App, Error, HttpServer}; -use opentelemetry::trace::TracerProvider; -use opentelemetry::{global, KeyValue}; +use std::{io, sync::LazyLock}; + +use actix_web::{ + body::MessageBody, + dev::{ServiceRequest, ServiceResponse}, + web, App, Error, HttpServer, +}; +use opentelemetry::{global, trace::TracerProvider, KeyValue}; use opentelemetry_otlp::WithExportConfig; use opentelemetry_sdk::{ propagation::TraceContextPropagator, runtime::TokioCurrentThread, trace::Config, Resource, }; use opentelemetry_semantic_conventions::resource; -use std::io; -use std::sync::LazyLock; use tracing::Span; use tracing_actix_web::{DefaultRootSpanBuilder, RootSpan, RootSpanBuilder, TracingLogger}; use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer}; diff --git a/tracing-actix-web/examples/opentelemetry/src/main.rs b/tracing-actix-web/examples/opentelemetry/src/main.rs index fab4dce84..86498f3b7 100644 --- a/tracing-actix-web/examples/opentelemetry/src/main.rs +++ b/tracing-actix-web/examples/opentelemetry/src/main.rs @@ -1,13 +1,12 @@ +use std::{io, sync::LazyLock}; + use actix_web::{web, App, HttpServer}; -use opentelemetry::trace::TracerProvider; -use opentelemetry::{global, KeyValue}; +use opentelemetry::{global, trace::TracerProvider, KeyValue}; use opentelemetry_otlp::WithExportConfig; use opentelemetry_sdk::{ propagation::TraceContextPropagator, runtime::TokioCurrentThread, trace::Config, Resource, }; use opentelemetry_semantic_conventions::resource; -use std::io; -use std::sync::LazyLock; use tracing_actix_web::TracingLogger; use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer}; use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry}; diff --git a/tracing-actix-web/examples/request-id-response-header/src/main.rs b/tracing-actix-web/examples/request-id-response-header/src/main.rs index 5f40550a1..6faae54bf 100644 --- a/tracing-actix-web/examples/request-id-response-header/src/main.rs +++ b/tracing-actix-web/examples/request-id-response-header/src/main.rs @@ -1,9 +1,10 @@ +use std::io; + use actix_web::{ dev::Service, http::header::{HeaderName, HeaderValue}, web, App, HttpMessage, HttpServer, }; -use std::io; use tracing_actix_web::{RequestId, TracingLogger}; async fn hello() -> &'static str { diff --git a/tracing-actix-web/src/middleware.rs b/tracing-actix-web/src/middleware.rs index 24af02de7..b3e06a7d9 100644 --- a/tracing-actix-web/src/middleware.rs +++ b/tracing-actix-web/src/middleware.rs @@ -1,13 +1,19 @@ -use crate::{DefaultRootSpanBuilder, RequestId, RootSpan, RootSpanBuilder}; -use actix_web::body::{BodySize, MessageBody}; -use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform}; -use actix_web::web::Bytes; -use actix_web::{Error, HttpMessage}; -use std::future::{ready, Future, Ready}; -use std::pin::Pin; -use std::task::{Context, Poll}; +use std::{ + future::{ready, Future, Ready}, + pin::Pin, + task::{Context, Poll}, +}; + +use actix_web::{ + body::{BodySize, MessageBody}, + dev::{Service, ServiceRequest, ServiceResponse, Transform}, + web::Bytes, + Error, HttpMessage, +}; use tracing::Span; +use crate::{DefaultRootSpanBuilder, RequestId, RootSpan, RootSpanBuilder}; + /// `TracingLogger` is a middleware to capture structured diagnostic when processing an HTTP request. /// Check the crate-level documentation for an in-depth introduction. /// diff --git a/tracing-actix-web/src/otel.rs b/tracing-actix-web/src/otel.rs index 7b9a4c692..89b39a49d 100644 --- a/tracing-actix-web/src/otel.rs +++ b/tracing-actix-web/src/otel.rs @@ -1,5 +1,5 @@ use actix_web::dev::ServiceRequest; - +use opentelemetry::propagation::Extractor; #[cfg(feature = "opentelemetry_0_13")] use opentelemetry_0_13_pkg as opentelemetry; #[cfg(feature = "opentelemetry_0_14")] @@ -26,7 +26,6 @@ use opentelemetry_0_23_pkg as opentelemetry; use opentelemetry_0_24_pkg as opentelemetry; #[cfg(feature = "opentelemetry_0_25")] use opentelemetry_0_25_pkg as opentelemetry; - #[cfg(feature = "opentelemetry_0_13")] use tracing_opentelemetry_0_12_pkg as tracing_opentelemetry; #[cfg(feature = "opentelemetry_0_14")] @@ -54,8 +53,6 @@ use tracing_opentelemetry_0_25_pkg as tracing_opentelemetry; #[cfg(feature = "opentelemetry_0_25")] use tracing_opentelemetry_0_26_pkg as tracing_opentelemetry; -use opentelemetry::propagation::Extractor; - pub(crate) struct RequestHeaderCarrier<'a> { headers: &'a actix_web::http::header::HeaderMap, } diff --git a/tracing-actix-web/src/request_id.rs b/tracing-actix-web/src/request_id.rs index f59a3c2fe..2c96f8da1 100644 --- a/tracing-actix-web/src/request_id.rs +++ b/tracing-actix-web/src/request_id.rs @@ -1,6 +1,6 @@ -use actix_web::{dev::Payload, HttpMessage}; -use actix_web::{FromRequest, HttpRequest, ResponseError}; use std::future::{ready, Ready}; + +use actix_web::{dev::Payload, FromRequest, HttpMessage, HttpRequest, ResponseError}; use uuid::Uuid; /// A unique identifier generated for each incoming request. diff --git a/tracing-actix-web/src/root_span.rs b/tracing-actix-web/src/root_span.rs index 624a44212..366326c68 100644 --- a/tracing-actix-web/src/root_span.rs +++ b/tracing-actix-web/src/root_span.rs @@ -1,6 +1,6 @@ -use actix_web::{dev::Payload, HttpMessage}; -use actix_web::{FromRequest, HttpRequest, ResponseError}; use std::future::{ready, Ready}; + +use actix_web::{dev::Payload, FromRequest, HttpMessage, HttpRequest, ResponseError}; use tracing::Span; #[derive(Clone)] diff --git a/tracing-actix-web/src/root_span_builder.rs b/tracing-actix-web/src/root_span_builder.rs index fba60f70f..619ff4267 100644 --- a/tracing-actix-web/src/root_span_builder.rs +++ b/tracing-actix-web/src/root_span_builder.rs @@ -1,10 +1,13 @@ -use crate::root_span; -use actix_web::body::MessageBody; -use actix_web::dev::{ServiceRequest, ServiceResponse}; -use actix_web::http::StatusCode; -use actix_web::{Error, ResponseError}; +use actix_web::{ + body::MessageBody, + dev::{ServiceRequest, ServiceResponse}, + http::StatusCode, + Error, ResponseError, +}; use tracing::Span; +use crate::root_span; + /// `RootSpanBuilder` allows you to customise the root span attached by /// [`TracingLogger`] to incoming requests. /// diff --git a/tracing-actix-web/src/root_span_macro.rs b/tracing-actix-web/src/root_span_macro.rs index 312f0e136..0ad6bcfb2 100644 --- a/tracing-actix-web/src/root_span_macro.rs +++ b/tracing-actix-web/src/root_span_macro.rs @@ -142,13 +142,16 @@ pub mod private { //! in the code generated by the `root_span` macro. //! Items in this module are not part of the public interface of `tracing-actix-web` - they are considered //! implementation details and will change without notice in patch, minor and major releases. - use crate::RequestId; - use actix_web::dev::ServiceRequest; - use actix_web::http::{Method, Version}; use std::borrow::Cow; + use actix_web::{ + dev::ServiceRequest, + http::{Method, Version}, + }; pub use tracing; + use crate::RequestId; + #[doc(hidden)] // We need to allow unused variables because the function // body is empty if the user of the library chose not to activate