77//! of an HTTP API
88//!
99//! For example, you have [`HTTP_REQUEST_METHOD`] and [`http_request_method`] for the
10- //! `http.request.method` field.
10+ //! `http.request.method` field.
1111//!
1212//! The naming follows [OpenTelemetry's semantic convention](https://opentelemetry.io/docs/specs/semconv/)
1313//! whenever possible.
1414//!
1515//! # Exhaustiveness
1616//!
17- //! The module doesn't cover the entirety of OpenTelemetry's semantic convention specification.
17+ //! The module doesn't cover the entirety of OpenTelemetry's semantic convention specification.\
1818//! Feel free to open a PR if you need a **stable** field that isn't currently covered!
1919
2020use pavex:: http:: { Method , Version } ;
@@ -24,36 +24,21 @@ use pavex::response::Response;
2424use pavex:: telemetry:: ServerRequestId ;
2525use tracing:: Value ;
2626
27+ // Re-export error-related logging fields and the functions to set them.
28+ pub use tracing_log_error:: fields:: * ;
29+
2730/// The field name for the HTTP method of the incoming request (if canonical),
2831/// according to [OpenTelemetry's semantic convention](https://opentelemetry.io/docs/specs/semconv/attributes-registry/http/).
2932///
3033/// Use [`http_request_method`] to populate the field.
3134pub const HTTP_REQUEST_METHOD : & str = "http.request.method" ;
3235
33- /// The field name to record the server-generated identifier for this request.
36+ /// The field name to record the server-generated identifier for this request.\
3437/// This field doesn't appear in OpenTelemetry's semantic convention specification.
3538///
3639/// Use [`http_request_server_id`] to populate the field.
3740pub const HTTP_REQUEST_SERVER_ID : & str = "http.request.server_id" ;
3841
39- /// The field name to record the `Display` representation of an error.
40- /// This field doesn't appear in OpenTelemetry's semantic convention specification.
41- ///
42- /// Use [`error_message`] to populate the field.
43- pub const ERROR_MESSAGE : & str = "error.message" ;
44-
45- /// The field name to record the `Debug` representation of an error.
46- /// This field doesn't appear in OpenTelemetry's semantic convention specification.
47- ///
48- /// Use [`error_message`] to populate the field.
49- pub const ERROR_DETAILS : & str = "error.details" ;
50-
51- /// The field name to record the chain of sources for an error.
52- /// This field doesn't appear in OpenTelemetry's semantic convention specification.
53- ///
54- /// Use [`error_source_chain`] to populate the field.
55- pub const ERROR_SOURCE_CHAIN : & str = "error.source_chain" ;
56-
5742/// The field name for the HTTP status code of the outgoing response,
5843/// according to [OpenTelemetry's semantic convention](https://opentelemetry.io/docs/specs/semconv/attributes-registry/http/).
5944///
@@ -164,30 +149,3 @@ pub fn user_agent_original(request_head: &RequestHead) -> impl Value + '_ {
164149 . map ( |h| h. to_str ( ) . unwrap_or_default ( ) )
165150 . unwrap_or_default ( )
166151}
167-
168- /// The canonical representation for the value in [`ERROR_MESSAGE`].
169- pub fn error_message < E : std:: fmt:: Display > ( e : E ) -> impl Value {
170- tracing:: field:: display ( e)
171- }
172-
173- /// The canonical representation for the value in [`ERROR_DETAILS`].
174- pub fn error_details < E : std:: fmt:: Debug > ( e : E ) -> impl Value {
175- tracing:: field:: debug ( e)
176- }
177-
178- /// The canonical representation for the value in [`ERROR_SOURCE_CHAIN`].
179- pub fn error_source_chain < E : std:: error:: Error > ( e : E ) -> impl Value {
180- _error_source_chain ( e)
181- }
182-
183- fn _error_source_chain < E : std:: error:: Error > ( e : E ) -> String {
184- use std:: fmt:: Write as _;
185-
186- let mut chain = String :: new ( ) ;
187- let mut source = e. source ( ) ;
188- while let Some ( s) = source {
189- let _ = writeln ! ( chain, "- {}" , s) ;
190- source = s. source ( ) ;
191- }
192- chain
193- }
0 commit comments