Closed taqtiqa-mark closed 2 years ago
Just to be clear, I'd expect that in 80-90% of cases this will suffice:
#[cfg_attr(feature = "tracing", server_send(level = trace, name = "Server::encode", skip = [dst,msg]))]
fn encode(msg: Encode<'_, Self::Outgoing>, dst: &mut Vec<u8>) -> crate::Result<Encoder> {
...
}
Sorry for bringing this up again but whats the advantage of this over a tower middleware like tower-http's Trace
? It can be configured to send opentelemetry compatible spans https://github.com/EmbarkStudios/server-framework/blob/main/src/middleware/trace/opentelemetry.rs, without adding anything to hyper.
.... whats the advantage of this over a tower middleware
I'm not sure - possibly none?
However, I don't use tower, nor do I have plans to.
Right now I'm trying to understand/debug some Hyper hanging behavior, also reported independently in currently open Hyper issues. So that is the immediate use case.
Looking, very superficially, at the tower examples: It appears they may capture data from the two spans that are in the current Hyper code base:
If that observation is correct, then this likely complements tower tracing?
Sorry for bringing this up again but whats the advantage of this over a tower middleware .... without adding anything to hyper.
After some clarification via Discord:
The idea here is to instrument the Hyper code itself.
While it is true that much data that passes through Hyper can be 'traced' by a Tower middleware, the purpose here is to trace the Hyper behavior, or more specifically mis-behavior.
The use case is not instrumenting/tracing a 3rd-party app, but rather instrumenting/tracing Hyper itself. For example when trying to debug something such as issue #2312 and similar.
I commented a bit in the pull request about direction.
Updates:
trace_*
attributes.RFC
Is your feature request related to a problem? Please describe.
Hyper tracing, per issue #2678.
This RFC is concerning the semantics of setting up tracing in a Hyper application.
Specifically, out of scope are the particular values for
field(...)
,skip(...)
,name
andtarget
parameters in the Tracinginstrument
attribute.A particular goal is to flexibly compose the tracing
#[instrument(...)]
attributeDescribe the solution you'd like
Built in tracing support that can be compiled out when not needed - zero runtime penalty when not used. Yet is flexible enough to (hopefully) satisfy the users of Hyper, and the Hyper project itself.
Describe alternatives you've considered
See PR #2697. Having abandoned several aspects such as layers.
Additional context
These Hyper tracing proc-macro-attributes would be behind a
cfg_attr
guard but that is not relevant right now.I have a proc-macro crate
hyper-tracing-attributes
that has the following functionality implemented to the point where I'm confident (code generation) the functionality proposed can be achieved.The proposal is:
hyperhttp-tracing-attributes
crate: I don't anticipate needing consumer/subscriber or layer specific attributes, but if they do end up being needed, one could use e.g. a ~hyper~http-tracing-<layer>-attributes
crate etc. In fact there is nothing Hyper specific (yet) about this crate and it could by used to generate Tracing#[instrument(...)]
attributes for any HTTP oriented codehttp-tracing-attributes
crate?~server_send
, etc naming per the finagle standard annotationstrace_field
trace_name
~trace_target
This would generate