Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add http reporter crate. #19

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

hannesg
Copy link

@hannesg hannesg commented Jul 26, 2018

Hi rust-zipkin team

I noticed that there is no http reporter around ( or at least I didn't find it ). So I wrote one.

This adds a new crate to the repository containing a http reporter. The reporter features batching of spans, reporting on a background thread and spawning on a tokio core.

Are you interested in integrating this? Otherwise I'd create a dedicate repository for it in my account.

This adds a new crate to the repository containing a http reporter. The
reporter features batching of spans, reporting on a background thread
and spawning on a tokio core.
@palantirtech
Copy link
Member

Thanks for your interest in palantir/rust-zipkin, @hannesg! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

Copy link
Member

@sfackler sfackler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I left some comments in a couple of places but this seems like a pretty good API for an HTTP reporter.

I do want to tweak Reporter to pass the Span in by value. I'll make a separate PR with that, which should let us avoid the SpanBuf type entirely by just directly serializing a Vec<Span>.


impl zipkin::Report for Reporter {

fn report(&self, span: &zipkin::Span) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we should really make report take the span by value which would allow us to avoid all of the custom Buf weirdness.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in #20!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thank you. That really simplifies writing a reporter. I'll update the code.

/// Starts building a new client using the supplied Uri.
pub fn new( uri : http::Uri ) -> Self {
let mut parts = uri.into_parts();
parts.path_and_query = Some( http::uri::PathAndQuery::from_static("/api/v2/spans") );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will break if the configured URI has a path (e.g. if the Zipkin server is behind a reverse proxy). We'll probably want to instead concatenate /api/v2/spans to the URI's path.

///
/// # Panics
/// When the OS fails to create the backing thread this method panics.
pub fn start_thread( self ) -> (thread::JoinHandle<()>, Reporter) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this is the only method defined on BuilderWithErrorHandler, it might make more sense to not have the separate type and instead just have a start_thread method on Builder which takes the error handler and starts up the thread there?

let handle = thread::Builder::new()
.name("zipkin-reporter-http".to_string())
.spawn(move ||{
hyper::rt::run(worker.then(move |r|{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify this a bit by using map_error instead of then.

sfackler and others added 2 commits August 13, 2018 23:34
This is strictly more flexible wrt e.g. sending the spans to a separate
thread, and we're not doing anything with the span after reporting it
anyway.

This makes the trait definition a bit weird but we can fix that in 0.4.
This adds a new crate to the repository containing a http reporter. The
reporter features batching of spans, reporting on a background thread
and spawning on a tokio core.
@vavrusa
Copy link

vavrusa commented Feb 19, 2019

Is this being worked on? I rebased in my branch and added a few more things, and it works okay. I could lend a hand if needed.

@vavrusa
Copy link

vavrusa commented Jun 12, 2019

Here it is in case you'd like to cherry pick the commits: https://github.com/vavrusa/rust-zipkin/tree/http_reporter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants