How to set component_span with Rack middleware?
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?
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
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.
PATH_INFO is likely to be variable, right? If so, it would explode the cardinality of span names which would cause usability (and also UI performance problems). The span name is a label in the UI.
I think the default should be left alone, but allow a function of env to be passed to customize. For example, that could clean up or otherwise format PATH_INFO such that it doesn't repeat endlessly (such as something with an identifier in it would). For those who happen to have low cardinality paths, they could choose to put the function you mention.
sg?
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 https://github.com/openzipkin/zipkin-api/pull/42 for http.route
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?
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
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?
