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

How to set component_span with Rack middleware? #96

Open
georgeu2000 opened this issue Jan 6, 2017 · 7 comments
Open

How to set component_span with Rack middleware? #96

georgeu2000 opened this issue Jan 6, 2017 · 7 comments

Comments

@georgeu2000
Copy link

We have the following config for a Sinatra App:

zipkin_config = { service_name:ENV[ '...' ],
                  service_port:settings.port,
                  sampled_as_boolean:false,
                  sample_rate: 1,
                  json_api_host: ENV[ '..' ]}
use ZipkinTracer::RackHandler, zipkin_config

The span is displayed as "post", which I guess comes from the request method. How can I set it to request method and request path?

@codefromthecrypt
Copy link
Member

the span name is currently hard-set. It could be possible to add a naming function instead, which could compose the value. A lot of instrumentation do things like this.

https://github.com/openzipkin/zipkin-ruby/blob/master/lib/zipkin-tracer/rack/zipkin-tracer.rb#L24

@georgeu2000
Copy link
Author

What if we change it to

@tracer.with_new_span(trace_id,"#{env['REQUEST_METHOD']} #{env['PATH_INFO']}".downcase) do ...

Since this is a default, it might be better to more explicit...? (Although I have zero context so this is just for my use case.)

I would be happy to do a PR.

@codefromthecrypt
Copy link
Member

codefromthecrypt commented Jan 7, 2017 via email

@codefromthecrypt
Copy link
Member

seems there's a long discussion of how to get what's currently referred to as "http.route" from the rails env https://stackoverflow.com/questions/42691729/how-to-find-current-abstract-route-in-rails-middware

see openzipkin/zipkin-api#42 for http.route

@jmhon08
Copy link
Contributor

jmhon08 commented Jun 14, 2018

I'm not exactly clear how to use the change in https://github.com/openzipkin/zipkin-api/pull/42/files to now get the route in the span name. How do I use HTTP_ROUTE in zipkin-ruby? Do I still want to do something like what @georgeu2000 suggested above, but instead do

@tracer.with_new_span(trace_id,"#{env['REQUEST_METHOD']} #{env['PATH_ROUTE']}".downcase)

and pass the route into env['PATH_ROUTE'] using what's described in your stackoverflow link?

@codefromthecrypt
Copy link
Member

here's the route-based span name logic we use in java if that helps? https://github.com/openzipkin/brave/blob/master/instrumentation/http/src/main/java/brave/http/HttpParser.java#L94

jmhon08 pushed a commit to jmhon08/zipkin-ruby that referenced this issue Jun 18, 2018
jmhon08 pushed a commit to jmhon08/zipkin-ruby that referenced this issue Jun 20, 2018
@jmhon08
Copy link
Contributor

jmhon08 commented Jun 20, 2018

OK I think I figured it out https://github.com/openzipkin/zipkin-ruby/pull/122/files. This looks good for our Rails app. Can you please review?

screen shot 2018-06-19 at 6 17 06 pm

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

No branches or pull requests

3 participants