Macro attributes for [tracing
] HTTP spans and events.
This Crate source can serve as a template when you want to customize
TracableError
handling. See
Support for recording and exporting telemetry asynchronously can be added via the following flags:
- `rt-tokio`: Spawn telemetry tasks using tokio’s multi-thread runtime.
- `rt-tokio-current-thread`: Spawn telemetry tasks on a separate runtime so that the main runtime won’t be blocked.
- `rt-async-std`: Spawn telemetry tasks using async-std’s runtime.
All examples use the Jaeger UI for viewing distributed span and trace data. To setup a Jaeger instance locally
podman run -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest
The traced data can be browsed at http://localhost:16686
.
The upstream echo
example setup to be traceable, using the tracing
crate.
cargo run --features="full traceable tracing/max_level_trace" --example echo_trace
In a second console/shell:
curl localhost:3000/echo -XPOST -d 'hello world'
curl localhost:3000/echo/uppercase -XPOST -d 'hello world'
curl localhost:3000/echo/reverse -XPOST -d 'hello world'
firefox http://localhost:16686
This Crate adopts the Ferrous Systems proc-macro pipeline:
flowchart LR;
subgraph M[proc-macro-attribute]
direction LR
P([Parse])--AST-->A([Analyze])--Model-->L([Lower])--IR-->C([CodeGen])
end
Input-. Rust .->M-. Rust .->Output;
To run an individual attribute test, say server_send
:
cargo test server_send -- --nocapture
Fork the Hyper source code, then clone,
and add one of the following patch sections to the Hyper Cargo.toml
-
depending on the stage of development:
# local/development version
[patch.crates-io]
tracing-attribute-http = { path = '../yours' }
# remote/deployed version
[patch.crates-io]
tracing-attribute-http = { git = 'https://github.com/you/yours' }
Next add a patch to the project Cargo.toml that uses Hyper - to ensure the Hyper you build on uses your error handling:
# local/development version
[dependencies]
hyper = { version = "0.14", features = ["full"] }
[patch.crates-io]
hyper = { path = '../hyper' }
# remote/deployed version
[patch.crates-io]
hyper = { git = 'https://github.com/you/hyper' }
Licensed under either of
-
Apache License, Version 2.0 (LICENSE-APACHE) or
-
MIT license (LICENSE-MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.