1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-12-18 01:33:59 +01:00

Adapt CI for tracing-actix-web

This commit is contained in:
Luca Palmieri 2024-09-29 10:25:03 +02:00
parent b3a26979a1
commit 013c5354f0
11 changed files with 60 additions and 41 deletions

View File

@ -44,7 +44,16 @@ jobs:
reporter: github-pr-check reporter: github-pr-check
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
clippy_flags: >- clippy_flags: >-
--workspace --all-features --tests --examples --bins -- --workspace --all-features --exclude tracing-actix-web --tests --examples --bins --
-A unknown_lints -D clippy::todo -D clippy::dbg_macro
- name: Check OTEL with Clippy
uses: giraffate/clippy-action@v1.0.1
with:
reporter: github-pr-check
github_token: ${{ secrets.GITHUB_TOKEN }}
clippy_flags: >-
--package tracing-actix-web --tests --examples --
-A unknown_lints -D clippy::todo -D clippy::dbg_macro -A unknown_lints -D clippy::todo -D clippy::dbg_macro
public-api-diff: public-api-diff:
@ -70,8 +79,8 @@ jobs:
- name: generate API diff - name: generate API diff
run: | run: |
for f in $(find -mindepth 2 -maxdepth 2 -name Cargo.toml); do for f in $(find -mindepth 2 -maxdepth 2 -not \( -path "./tracing-actix-web/Cargo.toml" -prune \) -name Cargo.toml); do
cargo public-api --manifest-path "$f" --all-features diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }} >> /tmp/diff.txt cargo public-api --manifest-path "$f" --all-features diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }} >> /tmp/diff.txt
done done
cargo public-api --manifest-path "tracing-actix-web/Cargo.toml" diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }} >> /tmp/diff.txt
cat /tmp/diff.txt cat /tmp/diff.txt

View File

@ -66,12 +66,12 @@ test-coverage-lcov: test-coverage
[group("test")] [group("test")]
[group("docs")] [group("docs")]
test-docs: test-docs:
cargo {{ toolchain }} test --doc --workspace --all-features --no-fail-fast -- --nocapture cargo {{ toolchain }} test --doc --workspace --all-features --no-fail-fast --exclude tracing-actix-web -- --nocapture
# Document crates in workspace. # Document crates in workspace.
[group("docs")] [group("docs")]
doc *args: && doc-set-workspace-crates doc *args: && doc-set-workspace-crates
RUSTDOCFLAGS="--cfg=docsrs -Dwarnings" cargo +nightly doc --workspace --all-features {{ args }} RUSTDOCFLAGS="--cfg=docsrs -Dwarnings" cargo +nightly doc --workspace --all-features --exclude tracing-actix-web {{ args }}
[group("docs")] [group("docs")]
[private] [private]

View File

@ -1,15 +1,16 @@
use actix_web::body::MessageBody; use std::{io, sync::LazyLock};
use actix_web::dev::{ServiceRequest, ServiceResponse};
use actix_web::{web, App, Error, HttpServer}; use actix_web::{
use opentelemetry::trace::TracerProvider; body::MessageBody,
use opentelemetry::{global, KeyValue}; dev::{ServiceRequest, ServiceResponse},
web, App, Error, HttpServer,
};
use opentelemetry::{global, trace::TracerProvider, KeyValue};
use opentelemetry_otlp::WithExportConfig; use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::{ use opentelemetry_sdk::{
propagation::TraceContextPropagator, runtime::TokioCurrentThread, trace::Config, Resource, propagation::TraceContextPropagator, runtime::TokioCurrentThread, trace::Config, Resource,
}; };
use opentelemetry_semantic_conventions::resource; use opentelemetry_semantic_conventions::resource;
use std::io;
use std::sync::LazyLock;
use tracing::Span; use tracing::Span;
use tracing_actix_web::{DefaultRootSpanBuilder, RootSpan, RootSpanBuilder, TracingLogger}; use tracing_actix_web::{DefaultRootSpanBuilder, RootSpan, RootSpanBuilder, TracingLogger};
use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer}; use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer};

View File

@ -1,13 +1,12 @@
use std::{io, sync::LazyLock};
use actix_web::{web, App, HttpServer}; use actix_web::{web, App, HttpServer};
use opentelemetry::trace::TracerProvider; use opentelemetry::{global, trace::TracerProvider, KeyValue};
use opentelemetry::{global, KeyValue};
use opentelemetry_otlp::WithExportConfig; use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::{ use opentelemetry_sdk::{
propagation::TraceContextPropagator, runtime::TokioCurrentThread, trace::Config, Resource, propagation::TraceContextPropagator, runtime::TokioCurrentThread, trace::Config, Resource,
}; };
use opentelemetry_semantic_conventions::resource; use opentelemetry_semantic_conventions::resource;
use std::io;
use std::sync::LazyLock;
use tracing_actix_web::TracingLogger; use tracing_actix_web::TracingLogger;
use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer}; use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer};
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry}; use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};

View File

@ -1,9 +1,10 @@
use std::io;
use actix_web::{ use actix_web::{
dev::Service, dev::Service,
http::header::{HeaderName, HeaderValue}, http::header::{HeaderName, HeaderValue},
web, App, HttpMessage, HttpServer, web, App, HttpMessage, HttpServer,
}; };
use std::io;
use tracing_actix_web::{RequestId, TracingLogger}; use tracing_actix_web::{RequestId, TracingLogger};
async fn hello() -> &'static str { async fn hello() -> &'static str {

View File

@ -1,13 +1,19 @@
use crate::{DefaultRootSpanBuilder, RequestId, RootSpan, RootSpanBuilder}; use std::{
use actix_web::body::{BodySize, MessageBody}; future::{ready, Future, Ready},
use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform}; pin::Pin,
use actix_web::web::Bytes; task::{Context, Poll},
use actix_web::{Error, HttpMessage}; };
use std::future::{ready, Future, Ready};
use std::pin::Pin; use actix_web::{
use std::task::{Context, Poll}; body::{BodySize, MessageBody},
dev::{Service, ServiceRequest, ServiceResponse, Transform},
web::Bytes,
Error, HttpMessage,
};
use tracing::Span; use tracing::Span;
use crate::{DefaultRootSpanBuilder, RequestId, RootSpan, RootSpanBuilder};
/// `TracingLogger` is a middleware to capture structured diagnostic when processing an HTTP request. /// `TracingLogger` is a middleware to capture structured diagnostic when processing an HTTP request.
/// Check the crate-level documentation for an in-depth introduction. /// Check the crate-level documentation for an in-depth introduction.
/// ///

View File

@ -1,5 +1,5 @@
use actix_web::dev::ServiceRequest; use actix_web::dev::ServiceRequest;
use opentelemetry::propagation::Extractor;
#[cfg(feature = "opentelemetry_0_13")] #[cfg(feature = "opentelemetry_0_13")]
use opentelemetry_0_13_pkg as opentelemetry; use opentelemetry_0_13_pkg as opentelemetry;
#[cfg(feature = "opentelemetry_0_14")] #[cfg(feature = "opentelemetry_0_14")]
@ -26,7 +26,6 @@ use opentelemetry_0_23_pkg as opentelemetry;
use opentelemetry_0_24_pkg as opentelemetry; use opentelemetry_0_24_pkg as opentelemetry;
#[cfg(feature = "opentelemetry_0_25")] #[cfg(feature = "opentelemetry_0_25")]
use opentelemetry_0_25_pkg as opentelemetry; use opentelemetry_0_25_pkg as opentelemetry;
#[cfg(feature = "opentelemetry_0_13")] #[cfg(feature = "opentelemetry_0_13")]
use tracing_opentelemetry_0_12_pkg as tracing_opentelemetry; use tracing_opentelemetry_0_12_pkg as tracing_opentelemetry;
#[cfg(feature = "opentelemetry_0_14")] #[cfg(feature = "opentelemetry_0_14")]
@ -54,8 +53,6 @@ use tracing_opentelemetry_0_25_pkg as tracing_opentelemetry;
#[cfg(feature = "opentelemetry_0_25")] #[cfg(feature = "opentelemetry_0_25")]
use tracing_opentelemetry_0_26_pkg as tracing_opentelemetry; use tracing_opentelemetry_0_26_pkg as tracing_opentelemetry;
use opentelemetry::propagation::Extractor;
pub(crate) struct RequestHeaderCarrier<'a> { pub(crate) struct RequestHeaderCarrier<'a> {
headers: &'a actix_web::http::header::HeaderMap, headers: &'a actix_web::http::header::HeaderMap,
} }

View File

@ -1,6 +1,6 @@
use actix_web::{dev::Payload, HttpMessage};
use actix_web::{FromRequest, HttpRequest, ResponseError};
use std::future::{ready, Ready}; use std::future::{ready, Ready};
use actix_web::{dev::Payload, FromRequest, HttpMessage, HttpRequest, ResponseError};
use uuid::Uuid; use uuid::Uuid;
/// A unique identifier generated for each incoming request. /// A unique identifier generated for each incoming request.

View File

@ -1,6 +1,6 @@
use actix_web::{dev::Payload, HttpMessage};
use actix_web::{FromRequest, HttpRequest, ResponseError};
use std::future::{ready, Ready}; use std::future::{ready, Ready};
use actix_web::{dev::Payload, FromRequest, HttpMessage, HttpRequest, ResponseError};
use tracing::Span; use tracing::Span;
#[derive(Clone)] #[derive(Clone)]

View File

@ -1,10 +1,13 @@
use crate::root_span; use actix_web::{
use actix_web::body::MessageBody; body::MessageBody,
use actix_web::dev::{ServiceRequest, ServiceResponse}; dev::{ServiceRequest, ServiceResponse},
use actix_web::http::StatusCode; http::StatusCode,
use actix_web::{Error, ResponseError}; Error, ResponseError,
};
use tracing::Span; use tracing::Span;
use crate::root_span;
/// `RootSpanBuilder` allows you to customise the root span attached by /// `RootSpanBuilder` allows you to customise the root span attached by
/// [`TracingLogger`] to incoming requests. /// [`TracingLogger`] to incoming requests.
/// ///

View File

@ -142,13 +142,16 @@ pub mod private {
//! in the code generated by the `root_span` macro. //! 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 //! 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. //! 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 std::borrow::Cow;
use actix_web::{
dev::ServiceRequest,
http::{Method, Version},
};
pub use tracing; pub use tracing;
use crate::RequestId;
#[doc(hidden)] #[doc(hidden)]
// We need to allow unused variables because the function // We need to allow unused variables because the function
// body is empty if the user of the library chose not to activate // body is empty if the user of the library chose not to activate