taqtiqa-mark / tracing-attributes-http

Macro attributes for Hyper tracing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tracing-attributes-http

Macro attributes for [tracing] HTTP spans and events. This Crate source can serve as a template when you want to customize TracableError handling. See

Features

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.

Examples

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.

Echo

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

Developers

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;

Tests

To run an individual attribute test, say server_send:

cargo test server_send -- --nocapture

TraceableError

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' }

License

Licensed under either of

at your option.

Contribution

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.

About

Macro attributes for Hyper tracing

License:Apache License 2.0


Languages

Language:Rust 100.0%