ddtrace 0.8.2 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.env +3 -1
  3. data/.gitignore +1 -0
  4. data/Appraisals +10 -0
  5. data/Rakefile +27 -1
  6. data/ddtrace.gemspec +2 -2
  7. data/docker-compose.yml +10 -0
  8. data/docs/GettingStarted.md +119 -0
  9. data/gemfiles/contrib.gemfile +5 -0
  10. data/gemfiles/contrib_old.gemfile +4 -0
  11. data/lib/ddtrace.rb +4 -11
  12. data/lib/ddtrace/buffer.rb +14 -0
  13. data/lib/ddtrace/contrib/aws/instrumentation.rb +43 -0
  14. data/lib/ddtrace/contrib/aws/parsed_context.rb +56 -0
  15. data/lib/ddtrace/contrib/aws/patcher.rb +56 -0
  16. data/lib/ddtrace/contrib/aws/services.rb +115 -0
  17. data/lib/ddtrace/contrib/dalli/instrumentation.rb +35 -0
  18. data/lib/ddtrace/contrib/dalli/patcher.rb +50 -0
  19. data/lib/ddtrace/contrib/dalli/quantize.rb +17 -0
  20. data/lib/ddtrace/contrib/faraday/middleware.rb +75 -0
  21. data/lib/ddtrace/contrib/faraday/patcher.rb +52 -0
  22. data/lib/ddtrace/contrib/mongodb/parsers.rb +57 -0
  23. data/lib/ddtrace/contrib/mongodb/patcher.rb +93 -0
  24. data/lib/ddtrace/contrib/mongodb/subscribers.rb +71 -0
  25. data/lib/ddtrace/contrib/rails/action_controller.rb +18 -19
  26. data/lib/ddtrace/contrib/rails/action_view.rb +51 -61
  27. data/lib/ddtrace/contrib/rails/active_support.rb +29 -73
  28. data/lib/ddtrace/contrib/rails/core_extensions.rb +191 -53
  29. data/lib/ddtrace/contrib/redis/quantize.rb +4 -6
  30. data/lib/ddtrace/contrib/resque/patcher.rb +38 -0
  31. data/lib/ddtrace/contrib/resque/resque_job.rb +31 -0
  32. data/lib/ddtrace/contrib/sucker_punch/exception_handler.rb +26 -0
  33. data/lib/ddtrace/contrib/sucker_punch/instrumentation.rb +60 -0
  34. data/lib/ddtrace/contrib/sucker_punch/patcher.rb +50 -0
  35. data/lib/ddtrace/ext/http.rb +1 -0
  36. data/lib/ddtrace/ext/mongo.rb +12 -0
  37. data/lib/ddtrace/monkey.rb +18 -0
  38. data/lib/ddtrace/pipeline.rb +46 -0
  39. data/lib/ddtrace/pipeline/span_filter.rb +38 -0
  40. data/lib/ddtrace/pipeline/span_processor.rb +20 -0
  41. data/lib/ddtrace/tracer.rb +18 -0
  42. data/lib/ddtrace/utils.rb +23 -3
  43. data/lib/ddtrace/version.rb +2 -2
  44. data/lib/ddtrace/workers.rb +30 -22
  45. data/lib/ddtrace/writer.rb +5 -7
  46. metadata +30 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fc0133019cee5e3bf12a664792a40ae95f320f7
4
- data.tar.gz: 43f7412b5613d8fffc74ddd204bec29c81ac5118
3
+ metadata.gz: 3896d5d634a6a65d95f815955b5e62108562a55c
4
+ data.tar.gz: a4d606173f9f92749e757bccc17a8524a91a916e
5
5
  SHA512:
6
- metadata.gz: 9739cdc4f56336a81e6366b30658fa0f6670c403e7d5d2dd6014a3545f69fb4b3188acd0fb8b499a3a15e211f97ac3d50a81e5f3cc76cb9b8f612eb2778b18ac
7
- data.tar.gz: 7b8c1ea6173c53e988548aca2a487357bf0022f23279e94c84097880c9a22866c3d0b9ef83ef34e18abfe85bdc12aa9760e55031b5ccd01020594ec78a2aa1a6
6
+ metadata.gz: 9ef525976240577dd0d39692749416765ace3b5542202d6b9db4674c8467c2d76c3bcfa8a4755e62b79fc31d4478c49960b10aba4607d3963d71754518fac240
7
+ data.tar.gz: 9eaf559a0c2d59798e8441c45342f3d3084358955e318677e42c506a95f548ad5b688eee4b0edf649e7f638befa6ee621337e6dd591fc9d12ebe011de30d8283
data/.env CHANGED
@@ -8,4 +8,6 @@ TEST_MYSQL_PASSWORD=mysql
8
8
  TEST_MYSQL_USER=mysql
9
9
  TEST_ELASTICSEARCH_REST_PORT=49200
10
10
  TEST_ELASTICSEARCH_NATIVE_PORT=49300
11
- TEST_REDIS_PORT=46379
11
+ TEST_REDIS_PORT=46379
12
+ TEST_MONGODB_PORT=57017
13
+ TEST_MEMCACHED_PORT=41121
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  *.gem
2
2
  *.rbc
3
+ *.swp
3
4
  /.config
4
5
  /coverage/
5
6
  /InstalledFiles
data/Appraisals CHANGED
@@ -111,6 +111,7 @@ end
111
111
  if RUBY_VERSION >= '2.2.2' && RUBY_PLATFORM != 'java'
112
112
  appraise 'contrib' do
113
113
  gem 'elasticsearch-transport'
114
+ gem 'mongo'
114
115
  gem 'grape'
115
116
  gem 'rack'
116
117
  gem 'rack-test'
@@ -120,10 +121,15 @@ if RUBY_VERSION >= '2.2.2' && RUBY_PLATFORM != 'java'
120
121
  gem 'sqlite3'
121
122
  gem 'activerecord'
122
123
  gem 'sidekiq'
124
+ gem 'aws-sdk'
125
+ gem 'sucker_punch'
126
+ gem 'dalli'
127
+ gem 'resque'
123
128
  end
124
129
  else
125
130
  appraise 'contrib-old' do
126
131
  gem 'elasticsearch-transport'
132
+ gem 'mongo'
127
133
  gem 'redis', '< 4.0.0'
128
134
  gem 'hiredis'
129
135
  gem 'rack', '1.4.7'
@@ -132,5 +138,9 @@ else
132
138
  gem 'sqlite3'
133
139
  gem 'activerecord', '3.2.22.5'
134
140
  gem 'sidekiq', '4.0.0'
141
+ gem 'aws-sdk', '~> 2.0'
142
+ gem 'sucker_punch'
143
+ gem 'dalli'
144
+ gem 'resque'
135
145
  end
136
146
  end
data/Rakefile CHANGED
@@ -51,7 +51,21 @@ namespace :test do
51
51
  t.test_files = FileList['test/contrib/rails/**/*disable_env*_test.rb']
52
52
  end
53
53
 
54
- [:elasticsearch, :http, :redis, :sinatra, :sidekiq, :rack, :grape].each do |contrib|
54
+ [
55
+ :elasticsearch,
56
+ :http,
57
+ :redis,
58
+ :sinatra,
59
+ :sidekiq,
60
+ :rack,
61
+ :faraday,
62
+ :grape,
63
+ :aws,
64
+ :sucker_punch,
65
+ :mongodb,
66
+ :resque,
67
+ :dalli
68
+ ].each do |contrib|
55
69
  Rake::TestTask.new(contrib) do |t|
56
70
  t.libs << %w[test lib]
57
71
  t.test_files = FileList["test/contrib/#{contrib}/*_test.rb"]
@@ -140,12 +154,24 @@ task :ci do
140
154
  sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:sidekiq'
141
155
  sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:rack'
142
156
  sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:grape'
157
+ sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:faraday'
158
+ sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:aws'
159
+ sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:mongodb'
160
+ sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:sucker_punch'
161
+ sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:dalli'
162
+ sh 'rvm $MRI_VERSIONS --verbose do appraisal contrib rake test:resque'
143
163
  sh 'rvm $MRI_OLD_VERSIONS --verbose do appraisal contrib-old rake test:monkey'
144
164
  sh 'rvm $MRI_OLD_VERSIONS --verbose do appraisal contrib-old rake test:elasticsearch'
145
165
  sh 'rvm $MRI_OLD_VERSIONS --verbose do appraisal contrib-old rake test:http'
146
166
  sh 'rvm $MRI_OLD_VERSIONS --verbose do appraisal contrib-old rake test:redis'
147
167
  sh 'rvm $MRI_OLD_VERSIONS --verbose do appraisal contrib-old rake test:sinatra'
148
168
  sh 'rvm $MRI_OLD_VERSIONS --verbose do appraisal contrib-old rake test:rack'
169
+ sh 'rvm $MRI_OLD_VERSIONS --verbose do appraisal contrib-old rake test:faraday'
170
+ sh 'rvm $MRI_OLD_VERSIONS --verbose do appraisal contrib-old rake test:aws'
171
+ sh 'rvm $MRI_OLD_VERSIONS --verbose do appraisal contrib-old rake test:mongodb'
172
+ sh 'rvm $MRI_OLD_VERSIONS --verbose do appraisal contrib-old rake test:sucker_punch'
173
+ sh 'rvm $MRI_OLD_VERSIONS --verbose do appraisal contrib-old rake test:dalli'
174
+ sh 'rvm $MRI_OLD_VERSIONS --verbose do appraisal contrib-old rake test:resque'
149
175
  sh 'rvm $SIDEKIQ_OLD_VERSIONS --verbose do appraisal contrib-old rake test:sidekiq'
150
176
  when 2
151
177
  sh 'rvm $RAILS3_VERSIONS --verbose do appraisal rails30-postgres rake test:rails'
@@ -35,8 +35,8 @@ EOS
35
35
  spec.add_dependency 'msgpack'
36
36
 
37
37
  spec.add_development_dependency 'rake', '~> 10.5'
38
- spec.add_development_dependency('rubocop', '~> 0.47') if RUBY_VERSION >= '2.1.0'
38
+ spec.add_development_dependency('rubocop', '= 0.49.1') if RUBY_VERSION >= '2.1.0'
39
39
  spec.add_development_dependency 'minitest', '= 5.10.1'
40
- spec.add_development_dependency 'appraisal', '~> 2.1'
40
+ spec.add_development_dependency 'appraisal', '~> 2.2'
41
41
  spec.add_development_dependency 'yard', '~> 0.9'
42
42
  end
@@ -32,6 +32,16 @@ redis:
32
32
  ports:
33
33
  - "127.0.0.1:${TEST_REDIS_PORT}:6379"
34
34
 
35
+ mongodb:
36
+ image: mongo:3.5
37
+ ports:
38
+ - "127.0.0.1:${TEST_MONGODB_PORT}:27017"
39
+
40
+ memcached:
41
+ image: memcached:1.5-alpine
42
+ ports:
43
+ - "127.0.0.1:${TEST_MEMCACHED_PORT}:11211"
44
+
35
45
  ddagent:
36
46
  image: datadog/docker-dd-agent
37
47
  environment:
@@ -30,6 +30,10 @@ provides auto instrumentation for the following web frameworks and libraries:
30
30
  * [Grape](#Grape)
31
31
  * [Active Record](#Active_Record)
32
32
  * [Elastic Search](#Elastic_Search)
33
+ * [MongoDB](#MongoDB)
34
+ * [Dalli](#Dalli)
35
+ * [Faraday](#Faraday)
36
+ * [SuckerPunch](#SuckerPunch)
33
37
  * [Net/HTTP](#Net_HTTP)
34
38
  * [Redis](#Redis)
35
39
 
@@ -70,6 +74,7 @@ of the Datadog tracer, you can override the following defaults:
70
74
  default_controller_service: 'rails-controller',
71
75
  default_cache_service: 'rails-cache',
72
76
  default_database_service: 'postgresql',
77
+ distributed_tracing_enabled: false,
73
78
  template_base_path: 'views/',
74
79
  tracer: Datadog.tracer,
75
80
  debug: false,
@@ -94,6 +99,8 @@ Available settings are:
94
99
  * ``default_cache_service``: set the cache service name used when tracing cache activity. Defaults to ``rails-cache``
95
100
  * ``default_database_service``: set the database service name used when tracing database activity. Defaults to the
96
101
  current adapter name, so if you're using PostgreSQL it will be ``postgres``.
102
+ * ``distributed_tracing_enabled``: enable [distributed tracing](#Distributed_Tracing) so that this service trace is
103
+ connected with a trace of another service if tracing headers are sent
97
104
  * ``default_grape_service``: set the service name used when tracing a Grape application mounted in your Rails router.
98
105
  Defaults to ``grape``
99
106
  * ``template_base_path``: used when the template name is parsed in the auto instrumented code. If you don't store
@@ -279,6 +286,27 @@ Note that if you enable both Elasticsearch and Net/HTTP integrations then
279
286
  for each call, two spans are created, one for Elasctisearch and one for Net/HTTP.
280
287
  This typically happens if you call ``patch_all`` to enable all integrations by default.
281
288
 
289
+ ### MongoDB
290
+
291
+ The integration traces any `Command` that is sent from the
292
+ [MongoDB Ruby Driver](https://github.com/mongodb/mongo-ruby-driver) to a MongoDB cluster.
293
+ By extension, Object Document Mappers (ODM) such as Mongoid are automatically instrumented
294
+ if they use the official Ruby driver. To activate the integration, simply:
295
+
296
+ require 'mongo'
297
+ require 'ddtrace'
298
+
299
+ Datadog::Monkey.patch_module(:mongo)
300
+
301
+ # now create a MongoDB client and use it as usual:
302
+ client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'artists')
303
+ collection = client[:people]
304
+ collection.insert_one({ name: 'Steve' })
305
+
306
+ # to change the MongoDB service, use the Pin object
307
+ pin = Datadog::Pin.get_from(client)
308
+ pin.service = 'mongodb-primary'
309
+
282
310
  ### Net/HTTP
283
311
 
284
312
  The Net/HTTP integration will trace any HTTP call using the standard lib
@@ -321,6 +349,51 @@ Or, by enabling distributed tracing for all HTTP calls:
321
349
 
322
350
  See [distributed tracing](#Distributed_Tracing) for details.
323
351
 
352
+ ### Faraday
353
+
354
+ The `faraday` integration is available through the `ddtrace` middleware:
355
+
356
+ require 'faraday'
357
+ require 'ddtrace'
358
+
359
+ Datadog::Monkey.patch_module(:faraday) # registers the tracing middleware
360
+
361
+ connection = Faraday.new('https://example.com') do |builder|
362
+ builder.use(:ddtrace, options)
363
+ builder.adapter Faraday.default_adapter
364
+ end
365
+
366
+ connection.get('/foo')
367
+
368
+ ### AWS
369
+
370
+ The AWS integration will trace every interaction (e.g. API calls) with AWS
371
+ services (S3, ElastiCache etc.).
372
+
373
+ require 'aws-sdk'
374
+ require 'ddtrace'
375
+
376
+ Datadog::Monkey.patch_module(:aws) # explicitly patch it
377
+
378
+ Aws::S3::Client.new.list_buckets # traced call
379
+
380
+ ### Dalli
381
+
382
+ Dalli integration will trace all calls to your ``memcached`` server:
383
+
384
+ require 'dalli'
385
+ require 'ddtrace'
386
+
387
+ # patch Dalli so all clients are traced
388
+ Datadog::Monkey.patch_module(:dalli)
389
+
390
+ client = Dalli::Client.new('localhost:11211', options)
391
+ client.set('abc', 123)
392
+
393
+ # to change Dalli service name, use the Pin class
394
+ pin = Datadog::Pin.get_from(client)
395
+ pin.service = 'primary-cache'
396
+
324
397
  ### Redis
325
398
 
326
399
  The Redis integration will trace simple calls as well as pipelines.
@@ -349,6 +422,21 @@ executions. It can be added as any other Sidekiq middleware:
349
422
  end
350
423
  end
351
424
 
425
+ ### SuckerPunch
426
+
427
+ The `sucker_punch` integration traces all scheduled jobs:
428
+
429
+ require 'ddtrace'
430
+
431
+ Datadog::Monkey.patch_module(:sucker_punch)
432
+
433
+ # the execution of this job is traced
434
+ LogJob.perform_async('login')
435
+
436
+ # to change SuckerPunch service name, use the Pin class
437
+ pin = Datadog::Pin.get_from(::SuckerPunch)
438
+ pin.service = 'deploy-queues'
439
+
352
440
  #### Configure the tracer middleware
353
441
 
354
442
  To modify the default configuration, simply pass arguments to the middleware.
@@ -387,6 +475,23 @@ giving precedence to the middleware settings. Inherited configurations are:
387
475
  * ``trace_agent_hostname``
388
476
  * ``trace_agent_port``
389
477
 
478
+ Where `options` is an optional `Hash` that accepts the following parameters:
479
+
480
+ | Key | Type | Default | Description |
481
+ | --- | --- | --- | --- |
482
+ | `split_by_domain` | Boolean | `false` | Uses the request domain as the service name when set to `true`. |
483
+ | `distributed_tracing` | Boolean | `false` | Propagates tracing context along the HTTP request when set to `true`. |
484
+ | `error_handler` | Callable | [Click Here](https://github.com/DataDog/dd-trace-rb/blob/4fe3bc9df032eac3cd294b0bebcc866080dbe04f/lib/ddtrace/contrib/faraday/middleware.rb#L11-L13) | A callable object that receives a single argument – the request environment. If it evaluates to a *truthy* value, the trace span is marked as an error. By default, only server-side errors (e.g. `5xx`) are flagged as errors. |
485
+
486
+ It's worth mentioning that `ddtrace` also supports instrumentation for the
487
+ `net/http` library, so if you're using it as farady's backend you might see
488
+ instrumentation both on `faraday` and `net/http` levels. If you want to avoid
489
+ multiple levels of instrumentation for your HTTP requests, remember that you can
490
+ always fine tune witch libraries are patched by calling:
491
+
492
+ Datadog::Monkey.patch([:foo, :bar])
493
+ # instead of Datadog::Monkey.patch_all
494
+
390
495
  ## Advanced usage
391
496
 
392
497
  ### Manual Instrumentation
@@ -659,6 +764,20 @@ provided you pass a ``:distributed_tracing_enabled`` option set to ``true``.
659
764
 
660
765
  This is disabled by default.
661
766
 
767
+ ### Processing Pipeline
768
+
769
+ Sometimes it might be interesting to intercept `Span` objects before they get
770
+ sent upstream. To achieve that, you can hook custom *processors* into the
771
+ pipeline using the method `Datadog::Pipeline.before_flush`:
772
+
773
+ Datadog::Pipeline.before_flush(
774
+ Datadog::Pipeline::SpanFilter.new { |span| span.resource =~ /PingController/ },
775
+ Datadog::Pipeline::SpanFilter.new { |span| span.get_tag('host') == 'localhost' }
776
+ Datadog::Pipeline::SpanProcessor.new { |span| span.resource.gsub!(/password=.*/, '') }
777
+ )
778
+
779
+ For more information, please refer to this [link](https://github.com/DataDog/dd-trace-rb/pull/214).
780
+
662
781
  ### Troubleshooting
663
782
 
664
783
  #### Logs
@@ -3,6 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "elasticsearch-transport"
6
+ gem "mongo"
6
7
  gem "grape"
7
8
  gem "rack"
8
9
  gem "rack-test"
@@ -12,5 +13,9 @@ gem "sinatra"
12
13
  gem "sqlite3"
13
14
  gem "activerecord"
14
15
  gem "sidekiq"
16
+ gem "aws-sdk"
17
+ gem "sucker_punch"
18
+ gem "dalli"
19
+ gem "resque"
15
20
 
16
21
  gemspec path: "../"
@@ -3,6 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "elasticsearch-transport"
6
+ gem "mongo"
6
7
  gem "redis", "< 4.0.0"
7
8
  gem "hiredis"
8
9
  gem "rack", "1.4.7"
@@ -11,5 +12,8 @@ gem "sinatra", "1.4.5"
11
12
  gem "sqlite3"
12
13
  gem "activerecord", "3.2.22.5"
13
14
  gem "sidekiq", "4.0.0"
15
+ gem "aws-sdk", "~> 2.0"
16
+ gem "sucker_punch"
17
+ gem "resque"
14
18
 
15
19
  gemspec path: "../"
@@ -2,6 +2,7 @@ require 'ddtrace/monkey'
2
2
  require 'ddtrace/pin'
3
3
  require 'ddtrace/tracer'
4
4
  require 'ddtrace/error'
5
+ require 'ddtrace/pipeline'
5
6
 
6
7
  # \Datadog global namespace that includes all tracing functionality for Tracer and Span classes.
7
8
  module Datadog
@@ -36,11 +37,13 @@ if defined?(Rails::VERSION)
36
37
  module Datadog
37
38
  # Railtie class initializes
38
39
  class Railtie < Rails::Railtie
40
+ # add instrumentation middlewares
41
+ options = {}
42
+ config.app_middleware.insert_before(0, Datadog::Contrib::Rack::TraceMiddleware, options)
39
43
  config.app_middleware.use(Datadog::Contrib::Rails::ExceptionMiddleware)
40
44
 
41
45
  # auto instrument Rails and third party components after
42
46
  # the framework initialization
43
- options = {}
44
47
  config.after_initialize do |app|
45
48
  Datadog::Contrib::Rails::Framework.configure(config: app.config)
46
49
  Datadog::Contrib::Rails::Framework.auto_instrument()
@@ -50,16 +53,6 @@ if defined?(Rails::VERSION)
50
53
  # override Rack Middleware configurations with Rails
51
54
  options.update(::Rails.configuration.datadog_trace)
52
55
  end
53
-
54
- # Configure datadog settings before building the middleware stack.
55
- # This is required because the middleware stack is frozen after
56
- # the initialization and so it's too late to add our tracing
57
- # functionalities.
58
- initializer :datadog_config, before: :build_middleware_stack do |app|
59
- app.config.middleware.insert_before(
60
- 0, Datadog::Contrib::Rack::TraceMiddleware, options
61
- )
62
- end
63
56
  end
64
57
  end
65
58
  else
@@ -10,11 +10,13 @@ module Datadog
10
10
 
11
11
  @mutex = Mutex.new()
12
12
  @traces = []
13
+ @closed = false
13
14
  end
14
15
 
15
16
  # Add a new ``trace`` in the local queue. This method doesn't block the execution
16
17
  # even if the buffer is full. In that case, a random trace is discarded.
17
18
  def push(trace)
19
+ return if @closed
18
20
  @mutex.synchronize do
19
21
  len = @traces.length
20
22
  if len < @max_size || @max_size <= 0
@@ -48,5 +50,17 @@ module Datadog
48
50
  return traces
49
51
  end
50
52
  end
53
+
54
+ def close
55
+ @mutex.synchronize do
56
+ @closed = true
57
+ end
58
+ end
59
+
60
+ def closed?
61
+ @mutex.synchronise do
62
+ return @closed
63
+ end
64
+ end
51
65
  end
52
66
  end
@@ -0,0 +1,43 @@
1
+ module Datadog
2
+ module Contrib
3
+ module Aws
4
+ # A Seahorse::Client::Plugin that enables instrumentation for all AWS services
5
+ class Instrumentation < Seahorse::Client::Plugin
6
+ def add_handlers(handlers, _)
7
+ handlers.add(Handler, step: :validate)
8
+ end
9
+ end
10
+
11
+ # Generates Spans for all interactions with AWS
12
+ class Handler < Seahorse::Client::Handler
13
+ def call(context)
14
+ pin = Datadog::Pin.get_from(::Aws)
15
+
16
+ return @handler.call(context) unless pin && pin.enabled?
17
+
18
+ pin.tracer.trace(RESOURCE) do |span|
19
+ result = @handler.call(context)
20
+ annotate!(span, pin, ParsedContext.new(context))
21
+ result
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def annotate!(span, pin, context)
28
+ span.service = pin.service
29
+ span.span_type = pin.app_type
30
+ span.name = context.safely(:resource)
31
+ span.resource = RESOURCE
32
+ span.set_tag('aws.agent', AGENT)
33
+ span.set_tag('aws.operation', context.safely(:operation))
34
+ span.set_tag('aws.region', context.safely(:region))
35
+ span.set_tag('path', context.safely(:path))
36
+ span.set_tag('host', context.safely(:host))
37
+ span.set_tag(Ext::HTTP::METHOD, context.safely(:http_method))
38
+ span.set_tag(Ext::HTTP::STATUS_CODE, context.safely(:status_code))
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end