ddtrace 0.17.3 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.env +2 -2
  3. data/Appraisals +4 -0
  4. data/CHANGELOG.md +21 -2
  5. data/Rakefile +31 -29
  6. data/docker-compose.yml +7 -7
  7. data/docs/GettingStarted.md +26 -2
  8. data/lib/ddtrace.rb +4 -0
  9. data/lib/ddtrace/augmentation.rb +13 -0
  10. data/lib/ddtrace/augmentation/method_wrapper.rb +20 -0
  11. data/lib/ddtrace/augmentation/method_wrapping.rb +38 -0
  12. data/lib/ddtrace/augmentation/shim.rb +102 -0
  13. data/lib/ddtrace/contrib/active_record/events/sql.rb +6 -2
  14. data/lib/ddtrace/contrib/active_record/patcher.rb +2 -0
  15. data/lib/ddtrace/contrib/active_record/patches/abstract_adapter.rb +72 -0
  16. data/lib/ddtrace/contrib/active_record/utils.rb +8 -18
  17. data/lib/ddtrace/contrib/aws/instrumentation.rb +15 -11
  18. data/lib/ddtrace/contrib/aws/patcher.rb +0 -11
  19. data/lib/ddtrace/contrib/configurable.rb +13 -9
  20. data/lib/ddtrace/contrib/rack/request_queue.rb +5 -1
  21. data/lib/ddtrace/contrib/shoryuken/configuration/settings.rb +14 -0
  22. data/lib/ddtrace/contrib/shoryuken/ext.rb +18 -0
  23. data/lib/ddtrace/contrib/shoryuken/integration.rb +35 -0
  24. data/lib/ddtrace/contrib/shoryuken/patcher.rb +30 -0
  25. data/lib/ddtrace/contrib/shoryuken/tracer.rb +37 -0
  26. data/lib/ddtrace/contrib/sidekiq/client_tracer.rb +35 -0
  27. data/lib/ddtrace/contrib/sidekiq/configuration/settings.rb +1 -0
  28. data/lib/ddtrace/contrib/sidekiq/ext.rb +2 -0
  29. data/lib/ddtrace/contrib/sidekiq/patcher.rb +9 -2
  30. data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +50 -0
  31. data/lib/ddtrace/contrib/sidekiq/tracing.rb +38 -0
  32. data/lib/ddtrace/sync_writer.rb +2 -1
  33. data/lib/ddtrace/transport.rb +6 -3
  34. data/lib/ddtrace/utils/database.rb +7 -3
  35. data/lib/ddtrace/version.rb +2 -2
  36. data/lib/ddtrace/writer.rb +1 -4
  37. metadata +15 -3
  38. data/lib/ddtrace/contrib/sidekiq/tracer.rb +0 -72
@@ -1,72 +0,0 @@
1
- require 'sidekiq/api'
2
-
3
- require 'ddtrace/ext/app_types'
4
- require 'ddtrace/contrib/sidekiq/ext'
5
-
6
- module Datadog
7
- module Contrib
8
- module Sidekiq
9
- # Tracer is a Sidekiq server-side middleware which traces executed jobs
10
- class Tracer
11
- def initialize(options = {})
12
- @tracer = options[:tracer] || Datadog.configuration[:sidekiq][:tracer]
13
- @sidekiq_service = options[:service_name] || Datadog.configuration[:sidekiq][:service_name]
14
- end
15
-
16
- def call(worker, job, queue)
17
- # If class is wrapping something else, the interesting resource info
18
- # is the underlying, wrapped class, and not the wrapper.
19
- resource = if job['wrapped']
20
- job['wrapped']
21
- else
22
- job['class']
23
- end
24
-
25
- # configure Sidekiq service
26
- service = sidekiq_service(resource_worker(resource))
27
- set_service_info(service)
28
-
29
- @tracer.trace(Ext::SPAN_JOB, service: service, span_type: Datadog::Ext::AppTypes::WORKER) do |span|
30
- span.resource = resource
31
- span.set_tag(Ext::TAG_JOB_ID, job['jid'])
32
- span.set_tag(Ext::TAG_JOB_RETRY, job['retry'])
33
- span.set_tag(Ext::TAG_JOB_QUEUE, job['queue'])
34
- span.set_tag(Ext::TAG_JOB_WRAPPER, job['class']) if job['wrapped']
35
- span.set_tag(Ext::TAG_JOB_DELAY, 1000.0 * (Time.now.utc.to_f - job['enqueued_at'].to_f))
36
-
37
- yield
38
- end
39
- end
40
-
41
- private
42
-
43
- # rubocop:disable Lint/HandleExceptions
44
- def resource_worker(resource)
45
- Object.const_get(resource)
46
- rescue NameError
47
- end
48
-
49
- def worker_config(worker)
50
- if worker.respond_to?(:datadog_tracer_config)
51
- worker.datadog_tracer_config
52
- else
53
- {}
54
- end
55
- end
56
-
57
- def sidekiq_service(resource)
58
- worker_config(resource).fetch(:service_name, @sidekiq_service)
59
- end
60
-
61
- def set_service_info(service)
62
- return if @tracer.services[service]
63
- @tracer.set_service_info(
64
- service,
65
- Ext::APP,
66
- Datadog::Ext::AppTypes::WORKER
67
- )
68
- end
69
- end
70
- end
71
- end
72
- end