GithubHelp home page GithubHelp logo

bbigras / opentelemetry-surf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from asaaki/opentelemetry-surf

0.0 2.0 0.0 79 KB

🔭🏄🏻‍♀️ OpenTelemetry integration for Surf

License: Apache License 2.0

Rust 100.00%

opentelemetry-surf's Introduction

🔭🏄🏻‍♀️
opentelemetry-surf

OpenTelemetry integration for Surf


Notes

  • It is heavily inspired by opentelemetry-tide crate; surf and tide share very similar middleware structure. Thank you, dear @http-rs folks! 🙇🏻‍♂️
  • It only implements very basic request tracing on the middleware layer. If something is missing, create a PR or open an issue and describe your desired feature.
  • (soon) It records http request/response life cycle events when used with isahc and its metrics enabled. (needs a change in http-client crate)
  • You probably do not want to use it in production. 🤷

How to use

# Run jaeger in background
docker run -d \
  -p6831:6831/udp -p6832:6832/udp -p16686:16686 -p14268:14268 \
  jaegertracing/all-in-one:latest


# Run simple client example with tracing middleware
cargo run --example simple

# Run metrics client example (uses isahc with metrics enabled)
cargo run --example metrics --features isahc-metrics

# Open browser and view the traces
firefox http://localhost:16686/

example jaeger trace

Code example

Cargo.toml

async-std = { version = "1.7", features = ["attributes"] }
opentelemetry = { version = "0.10", features = ["async-std"] }
opentelemetry-jaeger = { version = "0.9", features = ["async-std"] }
# opentelemetry-surf = "0.1" # not yet released
opentelemetry-surf = { git = "https://github.com/asaaki/opentelemetry-surf" }

client.rs

#[async_std::main]
async fn main() -> surf::Result<()> {
    let (tracer, _uninstall) = opentelemetry_jaeger::new_pipeline().install().unwrap();
    let otel_mw = opentelemetry_surf::OpenTelemetryTracingMiddleware::new(tracer);
    let client = surf::client().with(otel_mw);
    let res = client.get("https://httpbin.org/get").await?;
    dbg!(res);
    Ok(())
}

Cargo Features:

Safety

This crate uses #![forbid(unsafe_code)] to ensure everything is implemented in 100% Safe Rust.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

opentelemetry-surf's People

Contributors

asaaki avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.