opentelemetry-ruby-contrib
opentelemetry-ruby-contrib copied to clipboard
Add URL quantization callback support to Sinatra instrumentation
Our Rack instrumentation allows configuration of a URL quantization function https://github.com/open-telemetry/opentelemetry-ruby/blob/1c37b00dc82d490dace1f92739977aa4674d7039/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb#L122-L137
We should add the same functionality to the Sinatra instrumentation. @genebean reported this requirement in Gitter:
I am using the auto instrumentation of the Sinatra but need to account for url paramters so that
/api/v2/status/queue/info/1600289926679
is instead traced as/api/v2/status/queue/info/{job_id}
- any tips on how to do this?
Thanks! Please make sure that instrumentation/rack/README.md
and instrumentation/sinatra/README.md
are updated to include how to put that to use... I don't see anything about it at this time.
We can do this, but I think we should also use env['sinatra.route']
as the span name (by default). It is already a quantized low-cardinality string. For example, for this route:
get '/accounts/:id' do
...
end
sinatra.route
for a request with an actual id will always be "GET /accounts/:id"
.
@mwear would that be as simple as editing https://github.com/open-telemetry/opentelemetry-ruby/blob/master/instrumentation/sinatra/lib/opentelemetry/instrumentation/sinatra/middlewares/tracer_middleware.rb and replacing env['PATH_INFO']
with env['sinatra.route']
? If so, I will put up a PR
👋 This issue has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep
label to hold stale off permanently, or do nothing. If you do nothing this issue will be closed eventually by the stale bot.