Closed
Description
openedon Jan 9, 2020
Hey,
We have a couple of Sinatra apps that split logic into Sinatra subapps like described in
"Using Sinatra as Middleware" in Sinatra README.
The issue is that the subapps that are mounted into the main Sinatra app generate spans with less information and most importantly without the query path information.
I built a simple app to demonstrate the issue:
require 'bundler/inline'
gemfile(true) do
gem 'sinatra', '2.0.8.1'
gem 'ddtrace', '0.31.0'
end
require 'sinatra/base'
require 'ddtrace'
Datadog.configure do |c|
c.tracer enabled: true, debug: true
c.use :sinatra
end
class SubApp < Sinatra::Base
get '/subapp' do
'im a subapp!'
end
end
class App < Sinatra::Base
register Datadog::Contrib::Sinatra::Tracer
use SubApp
get '/app' do
'im an app!'
end
run!
end
(this can be placed into app.rb
and run with ruby app.rb
)
Then GET'ing /app
and /subapp
yields such spans:
Name: sinatra.request
Span ID: 993493109027999176
Parent ID: 0
Trace ID: 8546903515006022516
Type: web
Service: sinatra
Resource: GET /app
Error: 0
Start: 1578580744393947904
End: 1578580744394780928
Duration: 833000
Allocations: 345
Tags: [
http.url => /app,
http.method => GET,
sinatra.route.path => /app,
http.response.headers.content_type => text/html;charset=utf-8]
Metrics: [
system.pid => 54966.0,
http.status_code => 200.0,
_sampling_priority_v1 => 1.0]]
Name: sinatra.request
Span ID: 5146783070146725872
Parent ID: 0
Trace ID: 3033401100074248247
Type: web
Service: sinatra
Resource: sinatra.request
Error: 0
Start: 1578580741950976000
End: 1578580741954078976
Duration: 3103000
Allocations: 5754
Tags: [
http.response.headers.content_type => text/html;charset=utf-8]
Metrics: [
system.pid => 54966.0,
_sampling_priority_v1 => 1.0]]
As you can see GET /subapp
span does not have proper tags and resource name.
Expected behaviour: mounted Sinatra apps get the same detailed spans as the top-level Sinatra app.
This case also works correctly with NewRelic.
Thanks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment