From fc59c3d61f9f0f1045864535a35c59882d47d604 Mon Sep 17 00:00:00 2001 From: Ruben2424 <61056653+Ruben2424@users.noreply.github.com> Date: Sun, 23 Jun 2024 21:52:48 +0200 Subject: [PATCH] Follow up to tracing (#248) * change feature name from h3-quinn-tracing to tracing * change feature h3-tracing to tracing * change level to trace * fmt * CI file --- .github/workflows/CI.yml | 2 +- examples/Cargo.toml | 4 +-- h3-quinn/Cargo.toml | 2 +- h3-quinn/src/lib.rs | 40 ++++++++++++++--------------- h3/Cargo.toml | 2 +- h3/src/client/connection.rs | 14 +++++------ h3/src/client/stream.rs | 16 ++++++------ h3/src/config.rs | 2 +- h3/src/connection.rs | 50 ++++++++++++++++++------------------- h3/src/frame.rs | 4 +-- h3/src/proto/frame.rs | 10 ++++---- h3/src/qpack/decoder.rs | 4 +-- h3/src/server/connection.rs | 32 ++++++++++++------------ h3/src/server/request.rs | 6 ++--- h3/src/server/stream.rs | 14 +++++------ 15 files changed, 101 insertions(+), 101 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7180c4ae..e9a881ab 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -111,7 +111,7 @@ jobs: matrix: os: [ubuntu-latest] toolchain: [stable, beta] - features: [i-implement-a-third-party-backend-and-opt-into-breaking-changes, h3-tracing, 'h3-tracing,i-implement-a-third-party-backend-and-opt-into-breaking-changes'] + features: [i-implement-a-third-party-backend-and-opt-into-breaking-changes, tracing, 'tracing,i-implement-a-third-party-backend-and-opt-into-breaking-changes'] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 9511344d..420fbcc6 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" anyhow = "1.0" bytes = "1" futures = "0.3" -h3 = { path = "../h3", features = ["h3-tracing"] } -h3-quinn = { path = "../h3-quinn", features = ["h3-quinn-tracing"] } +h3 = { path = "../h3", features = ["tracing"] } +h3-quinn = { path = "../h3-quinn", features = ["tracing"] } h3-webtransport = { path = "../h3-webtransport" } http = "1" quinn = { version = "0.11", default-features = false, features = [ diff --git a/h3-quinn/Cargo.toml b/h3-quinn/Cargo.toml index 26a591b4..4f380bf0 100644 --- a/h3-quinn/Cargo.toml +++ b/h3-quinn/Cargo.toml @@ -24,4 +24,4 @@ tokio = { version = "1", features = ["io-util"], default-features = false } tracing = { version = "0.1.40", optional = true } [features] -h3-quinn-tracing = ["tracing"] +tracing = ["dep:tracing"] diff --git a/h3-quinn/src/lib.rs b/h3-quinn/src/lib.rs index 05441627..a05ce813 100644 --- a/h3-quinn/src/lib.rs +++ b/h3-quinn/src/lib.rs @@ -28,7 +28,7 @@ use h3::{ }; use tokio_util::sync::ReusableBoxFuture; -#[cfg(feature = "h3-quinn-tracing")] +#[cfg(feature = "tracing")] use tracing::instrument; /// A QUIC connection backed by Quinn @@ -158,7 +158,7 @@ where type OpenStreams = OpenStreams; type AcceptError = ConnectionError; - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_accept_bidi( &mut self, cx: &mut task::Context<'_>, @@ -173,7 +173,7 @@ where }))) } - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_accept_recv( &mut self, cx: &mut task::Context<'_>, @@ -202,7 +202,7 @@ where type BidiStream = BidiStream; type OpenError = ConnectionError; - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_open_bidi( &mut self, cx: &mut task::Context<'_>, @@ -221,7 +221,7 @@ where })) } - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_open_send( &mut self, cx: &mut task::Context<'_>, @@ -236,7 +236,7 @@ where Poll::Ready(Ok(Self::SendStream::new(send))) } - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn close(&mut self, code: h3::error::Code, reason: &[u8]) { self.conn.close( VarInt::from_u64(code.value()).expect("error code VarInt"), @@ -251,7 +251,7 @@ where { type Error = SendDatagramError; - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn send_datagram(&mut self, data: Datagram) -> Result<(), SendDatagramError> { // TODO investigate static buffer from known max datagram size let mut buf = BytesMut::new(); @@ -268,7 +268,7 @@ impl quic::RecvDatagramExt for Connection { type Error = ConnectionError; #[inline] - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_accept_datagram( &mut self, cx: &mut task::Context<'_>, @@ -299,7 +299,7 @@ where type BidiStream = BidiStream; type OpenError = ConnectionError; - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_open_bidi( &mut self, cx: &mut task::Context<'_>, @@ -318,7 +318,7 @@ where })) } - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_open_send( &mut self, cx: &mut task::Context<'_>, @@ -333,7 +333,7 @@ where Poll::Ready(Ok(Self::SendStream::new(send))) } - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn close(&mut self, code: h3::error::Code, reason: &[u8]) { self.conn.close( VarInt::from_u64(code.value()).expect("error code VarInt"), @@ -465,7 +465,7 @@ impl quic::RecvStream for RecvStream { type Buf = Bytes; type Error = ReadError; - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_data( &mut self, cx: &mut task::Context<'_>, @@ -482,7 +482,7 @@ impl quic::RecvStream for RecvStream { Poll::Ready(Ok(chunk?.map(|c| c.bytes))) } - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn stop_sending(&mut self, error_code: u64) { self.stream .as_mut() @@ -491,7 +491,7 @@ impl quic::RecvStream for RecvStream { .ok(); } - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn recv_id(&self) -> StreamId { self.stream .as_ref() @@ -589,7 +589,7 @@ where { type Error = SendStreamError; - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_ready(&mut self, cx: &mut task::Context<'_>) -> Poll> { if let Some(ref mut data) = self.writing { while data.has_remaining() { @@ -615,12 +615,12 @@ where Poll::Ready(Ok(())) } - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_finish(&mut self, _cx: &mut task::Context<'_>) -> Poll> { Poll::Ready(self.stream.as_mut().unwrap().finish().map_err(|e| e.into())) } - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn reset(&mut self, reset_code: u64) { let _ = self .stream @@ -629,7 +629,7 @@ where .reset(VarInt::from_u64(reset_code).unwrap_or(VarInt::MAX)); } - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn send_data>>(&mut self, data: D) -> Result<(), Self::Error> { if self.writing.is_some() { return Err(Self::Error::NotReady); @@ -638,7 +638,7 @@ where Ok(()) } - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn send_id(&self) -> StreamId { self.stream .as_ref() @@ -654,7 +654,7 @@ impl quic::SendStreamUnframed for SendStream where B: Buf, { - #[cfg_attr(feature = "h3-quinn-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_send( &mut self, cx: &mut task::Context<'_>, diff --git a/h3/Cargo.toml b/h3/Cargo.toml index 04a94c57..5d740e99 100644 --- a/h3/Cargo.toml +++ b/h3/Cargo.toml @@ -21,7 +21,7 @@ categories = [ [features] i-implement-a-third-party-backend-and-opt-into-breaking-changes = [] -h3-tracing = ["tracing"] +tracing = ["dep:tracing"] [dependencies] bytes = "1" diff --git a/h3/src/client/connection.rs b/h3/src/client/connection.rs index d6bf946b..49e9ed2f 100644 --- a/h3/src/client/connection.rs +++ b/h3/src/client/connection.rs @@ -10,7 +10,7 @@ use bytes::{Buf, BytesMut}; use futures_util::future; use http::request; -#[cfg(feature = "h3-tracing")] +#[cfg(feature = "tracing")] use tracing::{info, instrument, trace}; use crate::{ @@ -123,7 +123,7 @@ where B: Buf, { /// Send an HTTP/3 request to the server - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn send_request( &mut self, req: http::Request<()>, @@ -349,20 +349,20 @@ where B: Buf, { /// Initiate a graceful shutdown, accepting `max_push` potentially in-flight server pushes - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn shutdown(&mut self, _max_push: usize) -> Result<(), Error> { // TODO: Calculate remaining pushes once server push is implemented. self.inner.shutdown(&mut self.sent_closing, PushId(0)).await } /// Wait until the connection is closed - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn wait_idle(&mut self) -> Result<(), Error> { future::poll_fn(|cx| self.poll_close(cx)).await } /// Maintain the connection state until it is closed - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn poll_close(&mut self, cx: &mut Context<'_>) -> Poll> { while let Poll::Ready(result) = self.inner.poll_control(cx) { match result { @@ -386,7 +386,7 @@ where //# Once a server has provided new settings, //# clients MUST comply with those values. Ok(Frame::Settings(_)) => { - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] trace!("Got settings"); () } @@ -406,7 +406,7 @@ where } self.inner.process_goaway(&mut self.recv_closing, id)?; - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] info!("Server initiated graceful shutdown, last: StreamId({})", id); } diff --git a/h3/src/client/stream.rs b/h3/src/client/stream.rs index 978de81e..b94e40d4 100644 --- a/h3/src/client/stream.rs +++ b/h3/src/client/stream.rs @@ -1,7 +1,7 @@ use bytes::Buf; use futures_util::future; use http::{HeaderMap, Response}; -#[cfg(feature = "h3-tracing")] +#[cfg(feature = "tracing")] use tracing::instrument; use crate::{ @@ -84,7 +84,7 @@ where /// This should be called before trying to receive any data with [`recv_data()`]. /// /// [`recv_data()`]: #method.recv_data - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn recv_response(&mut self) -> Result, Error> { let mut frame = future::poll_fn(|cx| self.inner.stream.poll_next(cx)) .await @@ -144,13 +144,13 @@ where /// Receive some of the request body. // TODO what if called before recv_response ? - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn recv_data(&mut self) -> Result, Error> { self.inner.recv_data().await } /// Receive an optional set of trailers for the response. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn recv_trailers(&mut self) -> Result, Error> { let res = self.inner.recv_trailers().await; if let Err(ref e) = res { @@ -162,7 +162,7 @@ where } /// Tell the peer to stop sending into the underlying QUIC stream - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn stop_sending(&mut self, error_code: crate::error::Code) { // TODO take by value to prevent any further call as this request is cancelled // rename `cancel()` ? @@ -176,7 +176,7 @@ where B: Buf, { /// Send some data on the request body. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn send_data(&mut self, buf: B) -> Result<(), Error> { self.inner.send_data(buf).await } @@ -186,7 +186,7 @@ where /// Either [`RequestStream::finish`] or /// [`RequestStream::send_trailers`] must be called to finalize a /// request. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn send_trailers(&mut self, trailers: HeaderMap) -> Result<(), Error> { self.inner.send_trailers(trailers).await } @@ -196,7 +196,7 @@ where /// Either [`RequestStream::finish`] or /// [`RequestStream::send_trailers`] must be called to finalize a /// request. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn finish(&mut self) -> Result<(), Error> { self.inner.finish().await } diff --git a/h3/src/config.rs b/h3/src/config.rs index 1c1271f2..c2a6fe64 100644 --- a/h3/src/config.rs +++ b/h3/src/config.rs @@ -106,7 +106,7 @@ impl TryFrom for frame::Settings { match settings.insert(frame::SettingId::grease(), 0) { Ok(_) => (), Err(_err) => { - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] tracing::warn!("Error when adding the grease Setting. Reason {}", _err); } } diff --git a/h3/src/connection.rs b/h3/src/connection.rs index 43fa5d6f..a2fcf6ce 100644 --- a/h3/src/connection.rs +++ b/h3/src/connection.rs @@ -10,7 +10,7 @@ use futures_util::{future, ready}; use http::HeaderMap; use stream::WriteBuf; -#[cfg(feature = "h3-tracing")] +#[cfg(feature = "tracing")] use tracing::{instrument, warn}; use crate::{ @@ -169,7 +169,7 @@ where B: Buf, { /// Sends the settings and initializes the control streams - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn send_control_stream_headers(&mut self) -> Result<(), Error> { #[cfg(test)] if !self.config.send_settings { @@ -179,7 +179,7 @@ where let settings = frame::Settings::try_from(self.config) .map_err(|e| Code::H3_INTERNAL_ERROR.with_cause(e))?; - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] tracing::debug!("Sending server settings: {:#x?}", settings); //= https://www.rfc-editor.org/rfc/rfc9114#section-3.2 @@ -236,7 +236,7 @@ where } /// Initiates the connection and opens a control stream - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn new(mut conn: C, shared: SharedStateRef, config: Config) -> Result { //= https://www.rfc-editor.org/rfc/rfc9114#section-6.2 //# Endpoints SHOULD create the HTTP control stream as well as the @@ -293,7 +293,7 @@ where } /// Send GOAWAY with specified max_id, iff max_id is smaller than the previous one. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn shutdown( &mut self, sent_closing: &mut Option, @@ -322,7 +322,7 @@ where } #[allow(missing_docs)] - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn poll_accept_request( &mut self, cx: &mut Context<'_>, @@ -343,7 +343,7 @@ where /// Polls incoming streams /// /// Accepted streams which are not control, decoder, or encoder streams are buffer in `accepted_recv_streams` - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn poll_accept_recv(&mut self, cx: &mut Context<'_>) -> Result<(), Error> { if let Some(ref e) = self.shared.read("poll_accept_request").error { return Err(e.clone()); @@ -432,7 +432,7 @@ where } /// Waits for the control stream to be received and reads subsequent frames. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn poll_control(&mut self, cx: &mut Context<'_>) -> Poll, Error>> { if let Some(ref e) = self.shared.read("poll_accept_request").error { return Poll::Ready(Err(e.clone())); @@ -554,7 +554,7 @@ where Poll::Ready(res) } - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub(crate) fn process_goaway( &mut self, recv_closing: &mut Option, @@ -599,7 +599,7 @@ where /// Closes a Connection with code and reason. /// It returns an [`Error`] which can be returned. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn close>(&mut self, code: Code, reason: T) -> Error { self.shared.write("connection close err").error = Some(code.with_reason(reason.as_ref(), crate::error::ErrorLevel::ConnectionError)); @@ -608,7 +608,7 @@ where } // start grease stream and send data - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_grease_stream(&mut self, cx: &mut Context<'_>) -> Poll<()> { if matches!(self.grease_step, GreaseStatus::NotStarted(_)) { self.grease_step = match self.conn.poll_open_send(cx) { @@ -618,7 +618,7 @@ where // don't try again self.send_grease_stream_flag = false; - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] warn!("grease stream creation failed with"); return Poll::Ready(()); @@ -640,7 +640,7 @@ where { self.send_grease_stream_flag = false; - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] warn!("write data on grease stream failed with"); return Poll::Ready(()); @@ -659,7 +659,7 @@ where // don't try again self.send_grease_stream_flag = false; - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] warn!("write data on grease stream failed with"); return Poll::Ready(()); @@ -689,7 +689,7 @@ where // don't try again self.send_grease_stream_flag = false; - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] warn!("finish grease stream failed with"); return Poll::Ready(()); @@ -705,7 +705,7 @@ where } #[allow(missing_docs)] - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn accepted_streams_mut(&mut self) -> &mut AcceptedStreams { &mut self.accepted_streams } @@ -749,7 +749,7 @@ where S: quic::RecvStream, { /// Receive some of the request body. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn poll_recv_data( &mut self, cx: &mut Context<'_>, @@ -800,13 +800,13 @@ where } /// Receive some of the request body. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn recv_data(&mut self) -> Result, Error> { future::poll_fn(|cx| self.poll_recv_data(cx)).await } /// Receive trailers - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn recv_trailers(&mut self) -> Result, Error> { let mut trailers = if let Some(encoded) = self.trailers.take() { encoded @@ -875,7 +875,7 @@ where } #[allow(missing_docs)] - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn stop_sending(&mut self, err_code: Code) { self.stream.stop_sending(err_code); } @@ -887,7 +887,7 @@ where B: Buf, { /// Send some data on the response body. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn send_data(&mut self, buf: B) -> Result<(), Error> { let frame = Frame::Data(buf); @@ -898,7 +898,7 @@ where } /// Send a set of trailers to end the request. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn send_trailers(&mut self, trailers: HeaderMap) -> Result<(), Error> { //= https://www.rfc-editor.org/rfc/rfc9114#section-4.2 //= type=TODO @@ -929,13 +929,13 @@ where } /// Stops a stream with an error code - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn stop_stream(&mut self, code: Code) { self.stream.reset(code.into()); } #[allow(missing_docs)] - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn finish(&mut self) -> Result<(), Error> { if self.send_grease_frame { // send a grease frame once per Connection @@ -956,7 +956,7 @@ where S: quic::BidiStream, B: Buf, { - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub(crate) fn split( self, ) -> ( diff --git a/h3/src/frame.rs b/h3/src/frame.rs index fac41b19..0a74137d 100644 --- a/h3/src/frame.rs +++ b/h3/src/frame.rs @@ -2,7 +2,7 @@ use std::task::{Context, Poll}; use bytes::Buf; -#[cfg(feature = "h3-tracing")] +#[cfg(feature = "tracing")] use tracing::trace; use crate::stream::{BufRecvStream, WriteBuf}; @@ -229,7 +229,7 @@ impl FrameDecoder { match decoded { Err(frame::FrameError::UnknownFrame(_ty)) => { - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] trace!("ignore unknown frame type {:#x}", _ty); src.advance(pos); diff --git a/h3/src/proto/frame.rs b/h3/src/proto/frame.rs index 20f9d9c2..34d3770c 100644 --- a/h3/src/proto/frame.rs +++ b/h3/src/proto/frame.rs @@ -3,7 +3,7 @@ use std::{ convert::TryInto, fmt::{self, Debug}, }; -#[cfg(feature = "h3-tracing")] +#[cfg(feature = "tracing")] use tracing::trace; use crate::webtransport::SessionId; @@ -87,7 +87,7 @@ impl Frame { // // See: https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-http3/#section-4.2 if ty == FrameType::WEBTRANSPORT_BI_STREAM { - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] tracing::trace!("webtransport frame"); return Ok(Frame::WebTransportStream(SessionId::decode(buf)?)); @@ -107,7 +107,7 @@ impl Frame { let mut payload = buf.take(len as usize); - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] trace!("frame ty: {:?}", ty); let frame = match ty { @@ -129,7 +129,7 @@ impl Frame { }; if let Ok(_frame) = &frame { - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] trace!( "got frame {:?}, len: {}, remaining: {}", _frame, @@ -543,7 +543,7 @@ impl Settings { //# H3_SETTINGS_ERROR. settings.insert(identifier, value)?; } else { - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] tracing::debug!("Unsupported setting: {:#x?}", identifier); } } diff --git a/h3/src/qpack/decoder.rs b/h3/src/qpack/decoder.rs index 48c1bf7e..10bddb41 100644 --- a/h3/src/qpack/decoder.rs +++ b/h3/src/qpack/decoder.rs @@ -1,7 +1,7 @@ use bytes::{Buf, BufMut}; use std::{convert::TryInto, fmt, io::Cursor, num::TryFromIntError}; -#[cfg(feature = "h3-tracing")] +#[cfg(feature = "tracing")] use tracing::trace; use super::{ @@ -119,7 +119,7 @@ impl Decoder { let inserted_on_start = self.table.total_inserted(); while let Some(instruction) = self.parse_instruction(read)? { - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] trace!("instruction {:?}", instruction); match instruction { diff --git a/h3/src/server/connection.rs b/h3/src/server/connection.rs index cf7a0941..c4e5687d 100644 --- a/h3/src/server/connection.rs +++ b/h3/src/server/connection.rs @@ -37,7 +37,7 @@ use crate::{ use crate::server::request::ResolveRequest; -#[cfg(feature = "h3-tracing")] +#[cfg(feature = "tracing")] use tracing::{instrument, trace, warn}; use super::stream::{ReadDatagram, RequestStream}; @@ -90,13 +90,13 @@ where /// Use a custom [`super::builder::Builder`] with [`super::builder::builder()`] to create a connection /// with different settings. /// Provide a Connection which implements [`quic::Connection`]. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn new(conn: C) -> Result { super::builder::builder().build(conn).await } /// Closes the connection with a code and a reason. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn close>(&mut self, code: Code, reason: T) -> Error { self.inner.close(code, reason) } @@ -112,7 +112,7 @@ where /// It returns a tuple with a [`http::Request`] and an [`RequestStream`]. /// The [`http::Request`] is the received request from the client. /// The [`RequestStream`] can be used to send the response. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn accept( &mut self, ) -> Result, RequestStream)>, Error> { @@ -158,7 +158,7 @@ where /// This is needed as a bidirectional stream may be read as part of incoming webtransport /// bi-streams. If it turns out that the stream is *not* a `WEBTRANSPORT_STREAM` the request /// may still want to be handled and passed to the user. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn accept_with_frame( &mut self, mut stream: FrameStream, @@ -290,7 +290,7 @@ where /// Initiate a graceful shutdown, accepting `max_request` potentially still in-flight /// /// See [connection shutdown](https://www.rfc-editor.org/rfc/rfc9114.html#connection-shutdown) for more information. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn shutdown(&mut self, max_requests: usize) -> Result<(), Error> { let max_id = self .last_accepted_stream @@ -304,7 +304,7 @@ where /// /// This could be either a *Request* or a *WebTransportBiStream*, the first frame's type /// decides. - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn poll_accept_request( &mut self, cx: &mut Context<'_>, @@ -353,13 +353,13 @@ where } } - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub(crate) fn poll_control(&mut self, cx: &mut Context<'_>) -> Poll> { while (self.poll_next_control(cx)?).is_ready() {} Poll::Pending } - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub(crate) fn poll_next_control( &mut self, cx: &mut Context<'_>, @@ -368,13 +368,13 @@ where match &frame { Frame::Settings(_setting) => { - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] trace!("Got settings > {:?}", _setting); () } &Frame::Goaway(id) => self.inner.process_goaway(&mut self.recv_closing, id)?, _frame @ Frame::MaxPushId(_) | _frame @ Frame::CancelPush(_) => { - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] warn!("Control frame ignored {:?}", _frame); //= https://www.rfc-editor.org/rfc/rfc9114#section-7.2.3 @@ -405,7 +405,7 @@ where Poll::Ready(Ok(frame)) } - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn poll_requests_completion(&mut self, cx: &mut Context<'_>) -> Poll<()> { loop { match self.request_end_recv.poll_recv(cx) { @@ -435,13 +435,13 @@ where B: Buf, { /// Sends a datagram - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn send_datagram(&mut self, stream_id: StreamId, data: B) -> Result<(), Error> { self.inner .conn .send_datagram(Datagram::new(stream_id, data))?; - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] tracing::info!("Sent datagram"); Ok(()) @@ -454,7 +454,7 @@ where B: Buf, { /// Reads an incoming datagram - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn read_datagram(&mut self) -> ReadDatagram { ReadDatagram { conn: self, @@ -468,7 +468,7 @@ where C: quic::Connection, B: Buf, { - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] fn drop(&mut self) { self.inner.close(Code::H3_NO_ERROR, ""); } diff --git a/h3/src/server/request.rs b/h3/src/server/request.rs index 7d986c86..4414ca13 100644 --- a/h3/src/server/request.rs +++ b/h3/src/server/request.rs @@ -3,7 +3,7 @@ use std::convert::TryFrom; use bytes::Buf; use http::{Request, StatusCode}; -#[cfg(feature = "h3-tracing")] +#[cfg(feature = "tracing")] use tracing::instrument; use crate::{error::Code, proto::headers::Header, qpack, quic, Error}; @@ -31,7 +31,7 @@ impl> ResolveRequest { } /// Finishes the resolution of the request - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn resolve( mut self, ) -> Result<(Request<()>, RequestStream), Error> { @@ -93,7 +93,7 @@ impl> ResolveRequest { // send the grease frame only once // self.inner.send_grease_frame = false; - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] tracing::trace!("replying with: {:?}", req); Ok((req, self.request_stream)) diff --git a/h3/src/server/stream.rs b/h3/src/server/stream.rs index 11a9d0cd..975537ed 100644 --- a/h3/src/server/stream.rs +++ b/h3/src/server/stream.rs @@ -33,7 +33,7 @@ use crate::{ stream::{self}, }; -#[cfg(feature = "h3-tracing")] +#[cfg(feature = "tracing")] use tracing::{error, instrument}; /// Manage request and response transfer for an incoming request @@ -63,13 +63,13 @@ where B: Buf, { /// Receive data sent from the client - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn recv_data(&mut self) -> Result, Error> { self.inner.recv_data().await } /// Poll for data sent from the client - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn poll_recv_data( &mut self, cx: &mut Context<'_>, @@ -78,13 +78,13 @@ where } /// Receive an optional set of trailers for the request - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub async fn recv_trailers(&mut self) -> Result, Error> { self.inner.recv_trailers().await } /// Tell the peer to stop sending into the underlying QUIC stream - #[cfg_attr(feature = "h3-tracing", instrument(skip_all))] + #[cfg_attr(feature = "tracing", instrument(skip_all, level = "trace"))] pub fn stop_sending(&mut self, error_code: crate::error::Code) { self.inner.stream.stop_sending(error_code) } @@ -211,7 +211,7 @@ where impl Drop for RequestEnd { fn drop(&mut self) { if let Err(_error) = self.request_end.send(self.stream_id) { - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] error!( "failed to notify connection of request end: {} {}", self.stream_id, _error @@ -240,7 +240,7 @@ where type Output = Result>, Error>; fn poll(mut self: std::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - #[cfg(feature = "h3-tracing")] + #[cfg(feature = "tracing")] tracing::trace!("poll: read_datagram"); match ready!(self.conn.inner.conn.poll_accept_datagram(cx))? {