Code Monkey home page Code Monkey logo

Comments (6)

sile avatar sile commented on May 29, 2024 1

@andrewbanchich

I think that it's somewhat dangerous to depend on tokio heavily because some users (including me) may want to use this crate outside of the asynchronous world (e.g., with the regular thread model). Besides, indeed, tokio seems a defact standard async runtime, but there are some alternatives (e.g., async-std) that provide its own channel implementation. Some user may want to use rustracing with one of the alternatives.

Instead of switching the channel implementation to tokio based one, IMO, it seems good to extend Tracer and SpanReceiver to allow arbitrary channel type as a type parameter (I have no plan to implement this feature in the near future though...).


By the way, just FYI, this crate now uses crossbeam as the channel implementation (see sile/rustracing#4).

from rustracing_jaeger.

sile avatar sile commented on May 29, 2024

It seems interesting to support futures. But currently, rustracing_jaeger (and rustracing) heavily depends on std::sync::mpsc, so it is difficalt to integrated with futures smoothly.

If your are not annoying to spawn a thread dedicated for the reporting, it will be easiest way to use the thread as follows:

let (tracer, span_rx) = Tracer::new(rustracing::sampler::AllSampler);

// Spawns a reporting thread at the initialization phase in your application
std::thread::spawn(move || {
    let mut reporter = track_try_unwrap!(JaegerCompactReporter::new("example"));
    while let Ok(span) = span_rx.recv() {
        if reporter.report(&[span][..]).is_err() {
            break;
        }
    }
});

// The operations of `tracer` are not blocked, so it can be used in asynchronous code.

from rustracing_jaeger.

andrewbanchich avatar andrewbanchich commented on May 29, 2024

@sile Any update on this? Rust has had async/await for a while now and you could use Tokio's mpsc instead of std's.

from rustracing_jaeger.

sile avatar sile commented on May 29, 2024

Instead of switching the channel implementation to tokio based one, IMO, it seems good to extend Tracer and SpanReceiver to allow arbitrary channel type as a type parameter

I tried implementing this idea in sile/rustracing#9. If you think this PR is good, I'll merge it. > @andrewbanchich

from rustracing_jaeger.

andrewbanchich avatar andrewbanchich commented on May 29, 2024

That makes sense to me.

I've actually just switched to using the official opentelemetry crate alongside tracing and tracing-opentelemetry.

Thank you though!

from rustracing_jaeger.

sile avatar sile commented on May 29, 2024

@andrewbanchich No problem! Thank you for letteing me know that.

from rustracing_jaeger.

Related Issues (18)

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.