ddtrace 1.12.1 → 1.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +129 -9
  3. data/ext/ddtrace_profiling_native_extension/collectors_thread_context.c +97 -14
  4. data/ext/ddtrace_profiling_native_extension/extconf.rb +6 -0
  5. data/ext/ddtrace_profiling_native_extension/http_transport.c +19 -6
  6. data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +1 -1
  7. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +41 -2
  8. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +6 -0
  9. data/ext/ddtrace_profiling_native_extension/stack_recorder.c +6 -10
  10. data/ext/ddtrace_profiling_native_extension/time_helpers.c +40 -4
  11. data/ext/ddtrace_profiling_native_extension/time_helpers.h +14 -0
  12. data/lib/datadog/appsec/component.rb +9 -0
  13. data/lib/datadog/appsec/configuration/settings.rb +104 -195
  14. data/lib/datadog/appsec/configuration.rb +0 -79
  15. data/lib/datadog/appsec/contrib/auto_instrument.rb +2 -4
  16. data/lib/datadog/appsec/contrib/devise/event.rb +57 -0
  17. data/lib/datadog/appsec/contrib/devise/ext.rb +13 -0
  18. data/lib/datadog/appsec/contrib/devise/integration.rb +42 -0
  19. data/lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb +76 -0
  20. data/lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb +52 -0
  21. data/lib/datadog/appsec/contrib/devise/patcher.rb +45 -0
  22. data/lib/datadog/appsec/contrib/devise/resource.rb +35 -0
  23. data/lib/datadog/appsec/contrib/devise/tracking.rb +49 -0
  24. data/lib/datadog/appsec/contrib/rack/ext.rb +2 -1
  25. data/lib/datadog/appsec/contrib/rack/reactive/request.rb +1 -1
  26. data/lib/datadog/appsec/contrib/rack/reactive/request_body.rb +1 -1
  27. data/lib/datadog/appsec/contrib/rack/reactive/response.rb +1 -1
  28. data/lib/datadog/appsec/contrib/rack/request_middleware.rb +12 -7
  29. data/lib/datadog/appsec/contrib/rails/ext.rb +3 -2
  30. data/lib/datadog/appsec/contrib/rails/framework.rb +1 -3
  31. data/lib/datadog/appsec/contrib/rails/patcher.rb +8 -8
  32. data/lib/datadog/appsec/contrib/rails/reactive/action.rb +1 -1
  33. data/lib/datadog/appsec/contrib/sinatra/ext.rb +2 -1
  34. data/lib/datadog/appsec/contrib/sinatra/framework.rb +1 -3
  35. data/lib/datadog/appsec/contrib/sinatra/reactive/routed.rb +1 -1
  36. data/lib/datadog/appsec/event.rb +1 -1
  37. data/lib/datadog/appsec/extensions.rb +1 -130
  38. data/lib/datadog/appsec/monitor/reactive/set_user.rb +1 -1
  39. data/lib/datadog/appsec/processor.rb +1 -1
  40. data/lib/datadog/appsec/rate_limiter.rb +1 -1
  41. data/lib/datadog/appsec/remote.rb +1 -1
  42. data/lib/datadog/appsec.rb +1 -2
  43. data/lib/datadog/ci/configuration/settings.rb +6 -8
  44. data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +7 -5
  45. data/lib/datadog/ci/contrib/cucumber/ext.rb +10 -8
  46. data/lib/datadog/ci/contrib/minitest/configuration/settings.rb +35 -0
  47. data/lib/datadog/ci/contrib/minitest/ext.rb +21 -0
  48. data/lib/datadog/ci/contrib/minitest/integration.rb +49 -0
  49. data/lib/datadog/ci/contrib/minitest/patcher.rb +27 -0
  50. data/lib/datadog/ci/contrib/minitest/test_helper.rb +68 -0
  51. data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +7 -5
  52. data/lib/datadog/ci/contrib/rspec/ext.rb +9 -7
  53. data/lib/datadog/ci.rb +1 -0
  54. data/lib/datadog/core/backport.rb +51 -0
  55. data/lib/datadog/core/configuration/agent_settings_resolver.rb +9 -5
  56. data/lib/datadog/core/configuration/base.rb +5 -5
  57. data/lib/datadog/core/configuration/components.rb +6 -1
  58. data/lib/datadog/core/configuration/ext.rb +7 -5
  59. data/lib/datadog/core/configuration/option.rb +269 -19
  60. data/lib/datadog/core/configuration/option_definition.rb +76 -11
  61. data/lib/datadog/core/configuration/options.rb +22 -10
  62. data/lib/datadog/core/configuration/settings.rb +139 -61
  63. data/lib/datadog/core/environment/execution.rb +55 -0
  64. data/lib/datadog/core/environment/ext.rb +13 -11
  65. data/lib/datadog/core/environment/yjit.rb +58 -0
  66. data/lib/datadog/core/git/ext.rb +24 -22
  67. data/lib/datadog/core/logging/ext.rb +3 -1
  68. data/lib/datadog/core/metrics/ext.rb +7 -5
  69. data/lib/datadog/core/remote/client/capabilities.rb +5 -0
  70. data/lib/datadog/core/remote/client.rb +3 -0
  71. data/lib/datadog/core/remote/component.rb +25 -34
  72. data/lib/datadog/core/remote/configuration/content.rb +28 -1
  73. data/lib/datadog/core/remote/configuration/repository.rb +3 -1
  74. data/lib/datadog/core/remote/ext.rb +1 -1
  75. data/lib/datadog/core/remote/negotiation.rb +17 -4
  76. data/lib/datadog/core/runtime/ext.rb +22 -12
  77. data/lib/datadog/core/runtime/metrics.rb +43 -0
  78. data/lib/datadog/core/telemetry/client.rb +12 -2
  79. data/lib/datadog/core/telemetry/emitter.rb +4 -2
  80. data/lib/datadog/core/telemetry/event.rb +19 -4
  81. data/lib/datadog/core/telemetry/ext.rb +4 -1
  82. data/lib/datadog/core/telemetry/heartbeat.rb +2 -4
  83. data/lib/datadog/core/telemetry/http/ext.rb +10 -8
  84. data/lib/datadog/core/telemetry/http/transport.rb +1 -0
  85. data/lib/datadog/core/telemetry/v2/app_client_configuration_change.rb +41 -0
  86. data/lib/datadog/core/telemetry/v2/request.rb +29 -0
  87. data/lib/datadog/core/transport/http/client.rb +1 -1
  88. data/lib/datadog/core/transport/http/config.rb +10 -0
  89. data/lib/datadog/core/utils/duration.rb +52 -0
  90. data/lib/datadog/core/utils/hash.rb +47 -0
  91. data/lib/datadog/core/utils/network.rb +1 -1
  92. data/lib/datadog/core/utils/safe_dup.rb +27 -20
  93. data/lib/datadog/core/utils.rb +1 -1
  94. data/lib/datadog/core/workers/async.rb +2 -2
  95. data/lib/datadog/kit/appsec/events.rb +139 -89
  96. data/lib/datadog/kit/identity.rb +80 -65
  97. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +3 -0
  98. data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -0
  99. data/lib/datadog/profiling/collectors/thread_context.rb +9 -2
  100. data/lib/datadog/profiling/component.rb +41 -9
  101. data/lib/datadog/profiling/exporter.rb +5 -1
  102. data/lib/datadog/profiling/flush.rb +9 -2
  103. data/lib/datadog/profiling/http_transport.rb +13 -3
  104. data/lib/datadog/profiling/load_native_extension.rb +7 -1
  105. data/lib/datadog/profiling.rb +11 -1
  106. data/lib/datadog/tracing/component.rb +58 -6
  107. data/lib/datadog/tracing/configuration/dynamic/option.rb +71 -0
  108. data/lib/datadog/tracing/configuration/dynamic.rb +64 -0
  109. data/lib/datadog/tracing/configuration/ext.rb +35 -32
  110. data/lib/datadog/tracing/configuration/http.rb +74 -0
  111. data/lib/datadog/tracing/configuration/settings.rb +106 -92
  112. data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +9 -6
  113. data/lib/datadog/tracing/contrib/action_cable/ext.rb +20 -18
  114. data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +9 -6
  115. data/lib/datadog/tracing/contrib/action_mailer/ext.rb +20 -18
  116. data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +8 -6
  117. data/lib/datadog/tracing/contrib/action_pack/ext.rb +10 -8
  118. data/lib/datadog/tracing/contrib/action_view/configuration/settings.rb +9 -6
  119. data/lib/datadog/tracing/contrib/action_view/ext.rb +12 -10
  120. data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +13 -7
  121. data/lib/datadog/tracing/contrib/active_job/ext.rb +25 -23
  122. data/lib/datadog/tracing/contrib/active_job/log_injection.rb +1 -1
  123. data/lib/datadog/tracing/contrib/active_job/patcher.rb +1 -1
  124. data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +9 -6
  125. data/lib/datadog/tracing/contrib/active_model_serializers/ext.rb +12 -10
  126. data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +9 -7
  127. data/lib/datadog/tracing/contrib/active_record/events/sql.rb +0 -8
  128. data/lib/datadog/tracing/contrib/active_record/ext.rb +17 -15
  129. data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +0 -5
  130. data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +9 -7
  131. data/lib/datadog/tracing/contrib/active_support/ext.rb +18 -16
  132. data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +14 -7
  133. data/lib/datadog/tracing/contrib/aws/ext.rb +37 -24
  134. data/lib/datadog/tracing/contrib/aws/instrumentation.rb +9 -5
  135. data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +3 -2
  136. data/lib/datadog/tracing/contrib/concurrent_ruby/ext.rb +4 -2
  137. data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +14 -7
  138. data/lib/datadog/tracing/contrib/dalli/ext.rb +19 -11
  139. data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +8 -6
  140. data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +13 -7
  141. data/lib/datadog/tracing/contrib/delayed_job/ext.rb +16 -14
  142. data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +14 -7
  143. data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +21 -15
  144. data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +8 -5
  145. data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +16 -9
  146. data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +43 -3
  147. data/lib/datadog/tracing/contrib/ethon/ext.rb +19 -11
  148. data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +0 -5
  149. data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +19 -10
  150. data/lib/datadog/tracing/contrib/excon/ext.rb +16 -8
  151. data/lib/datadog/tracing/contrib/excon/middleware.rb +20 -5
  152. data/lib/datadog/tracing/contrib/ext.rb +23 -1
  153. data/lib/datadog/tracing/contrib/extensions.rb +32 -0
  154. data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +20 -10
  155. data/lib/datadog/tracing/contrib/faraday/ext.rb +16 -8
  156. data/lib/datadog/tracing/contrib/faraday/middleware.rb +16 -5
  157. data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +8 -6
  158. data/lib/datadog/tracing/contrib/grape/ext.rb +16 -14
  159. data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +8 -6
  160. data/lib/datadog/tracing/contrib/graphql/ext.rb +7 -5
  161. data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +19 -9
  162. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +29 -20
  163. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +21 -20
  164. data/lib/datadog/tracing/contrib/grpc/ext.rb +16 -13
  165. data/lib/datadog/tracing/contrib/grpc/formatting.rb +127 -0
  166. data/lib/datadog/tracing/contrib/hanami/configuration/settings.rb +3 -2
  167. data/lib/datadog/tracing/contrib/hanami/ext.rb +10 -8
  168. data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +4 -7
  169. data/lib/datadog/tracing/contrib/http/configuration/settings.rb +33 -11
  170. data/lib/datadog/tracing/contrib/http/ext.rb +16 -9
  171. data/lib/datadog/tracing/contrib/http/instrumentation.rb +22 -7
  172. data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +33 -11
  173. data/lib/datadog/tracing/contrib/httpclient/ext.rb +17 -9
  174. data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +17 -5
  175. data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +33 -11
  176. data/lib/datadog/tracing/contrib/httprb/ext.rb +16 -9
  177. data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +17 -5
  178. data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +9 -6
  179. data/lib/datadog/tracing/contrib/kafka/ext.rb +42 -39
  180. data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +3 -2
  181. data/lib/datadog/tracing/contrib/lograge/ext.rb +3 -1
  182. data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +1 -0
  183. data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +14 -7
  184. data/lib/datadog/tracing/contrib/mongodb/ext.rb +20 -16
  185. data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +9 -5
  186. data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +17 -14
  187. data/lib/datadog/tracing/contrib/mysql2/ext.rb +15 -10
  188. data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +9 -5
  189. data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +52 -0
  190. data/lib/datadog/tracing/contrib/opensearch/ext.rb +37 -0
  191. data/lib/datadog/tracing/contrib/opensearch/integration.rb +44 -0
  192. data/lib/datadog/tracing/contrib/opensearch/patcher.rb +128 -0
  193. data/lib/datadog/tracing/contrib/opensearch/quantize.rb +81 -0
  194. data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +17 -14
  195. data/lib/datadog/tracing/contrib/pg/ext.rb +22 -19
  196. data/lib/datadog/tracing/contrib/pg/instrumentation.rb +9 -5
  197. data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +14 -7
  198. data/lib/datadog/tracing/contrib/presto/ext.rb +25 -20
  199. data/lib/datadog/tracing/contrib/presto/instrumentation.rb +9 -5
  200. data/lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb +12 -10
  201. data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +12 -8
  202. data/lib/datadog/tracing/contrib/qless/ext.rb +14 -12
  203. data/lib/datadog/tracing/contrib/que/configuration/settings.rb +21 -12
  204. data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +9 -7
  205. data/lib/datadog/tracing/contrib/racecar/event.rb +0 -5
  206. data/lib/datadog/tracing/contrib/racecar/ext.rb +20 -18
  207. data/lib/datadog/tracing/contrib/rack/configuration/settings.rb +16 -12
  208. data/lib/datadog/tracing/contrib/rack/ext.rb +18 -16
  209. data/lib/datadog/tracing/contrib/rack/header_collection.rb +3 -0
  210. data/lib/datadog/tracing/contrib/rack/header_tagging.rb +53 -0
  211. data/lib/datadog/tracing/contrib/rack/middlewares.rb +8 -49
  212. data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +15 -11
  213. data/lib/datadog/tracing/contrib/rails/ext.rb +7 -5
  214. data/lib/datadog/tracing/contrib/rails/log_injection.rb +7 -10
  215. data/lib/datadog/tracing/contrib/rails/patcher.rb +10 -41
  216. data/lib/datadog/tracing/contrib/rails/railtie.rb +3 -3
  217. data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +12 -9
  218. data/lib/datadog/tracing/contrib/rake/ext.rb +14 -12
  219. data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +17 -9
  220. data/lib/datadog/tracing/contrib/redis/ext.rb +22 -15
  221. data/lib/datadog/tracing/contrib/redis/tags.rb +9 -5
  222. data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +13 -7
  223. data/lib/datadog/tracing/contrib/resque/ext.rb +9 -7
  224. data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +16 -9
  225. data/lib/datadog/tracing/contrib/rest_client/ext.rb +15 -8
  226. data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +20 -5
  227. data/lib/datadog/tracing/contrib/roda/configuration/settings.rb +9 -6
  228. data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +3 -2
  229. data/lib/datadog/tracing/contrib/semantic_logger/ext.rb +3 -1
  230. data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +1 -0
  231. data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +9 -6
  232. data/lib/datadog/tracing/contrib/sequel/ext.rb +10 -8
  233. data/lib/datadog/tracing/contrib/sequel/utils.rb +2 -7
  234. data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +14 -8
  235. data/lib/datadog/tracing/contrib/shoryuken/ext.rb +14 -12
  236. data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +18 -11
  237. data/lib/datadog/tracing/contrib/sidekiq/ext.rb +32 -30
  238. data/lib/datadog/tracing/contrib/sinatra/configuration/settings.rb +11 -9
  239. data/lib/datadog/tracing/contrib/sinatra/env.rb +0 -17
  240. data/lib/datadog/tracing/contrib/sinatra/ext.rb +21 -19
  241. data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +3 -14
  242. data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +14 -8
  243. data/lib/datadog/tracing/contrib/sneakers/ext.rb +1 -0
  244. data/lib/datadog/tracing/contrib/sneakers/tracer.rb +1 -1
  245. data/lib/datadog/tracing/contrib/span_attribute_schema.rb +74 -10
  246. data/lib/datadog/tracing/contrib/stripe/configuration/settings.rb +9 -6
  247. data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +9 -6
  248. data/lib/datadog/tracing/contrib/sucker_punch/ext.rb +15 -13
  249. data/lib/datadog/tracing/contrib/utils/database.rb +5 -3
  250. data/lib/datadog/tracing/contrib.rb +1 -0
  251. data/lib/datadog/tracing/correlation.rb +9 -12
  252. data/lib/datadog/tracing/diagnostics/ext.rb +21 -19
  253. data/lib/datadog/tracing/distributed/b3_multi.rb +2 -2
  254. data/lib/datadog/tracing/distributed/b3_single.rb +1 -1
  255. data/lib/datadog/tracing/distributed/trace_context.rb +52 -17
  256. data/lib/datadog/tracing/metadata/ext.rb +9 -6
  257. data/lib/datadog/tracing/remote.rb +78 -0
  258. data/lib/datadog/tracing/sampling/rule_sampler.rb +29 -0
  259. data/lib/datadog/tracing/span_operation.rb +3 -15
  260. data/lib/datadog/tracing/trace_operation.rb +16 -3
  261. data/lib/datadog/tracing/trace_segment.rb +5 -2
  262. data/lib/datadog/tracing/tracer.rb +10 -1
  263. data/lib/ddtrace/transport/ext.rb +15 -9
  264. data/lib/ddtrace/transport/trace_formatter.rb +9 -0
  265. data/lib/ddtrace/version.rb +8 -11
  266. metadata +36 -7
  267. data/lib/datadog/tracing/contrib/sinatra/headers.rb +0 -35
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Tracing
3
5
  module Contrib
@@ -5,36 +7,36 @@ module Datadog
5
7
  # Sidekiq integration constants
6
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
7
9
  module Ext
8
- CLIENT_SERVICE_NAME = 'sidekiq-client'.freeze
9
- ENV_ENABLED = 'DD_TRACE_SIDEKIQ_ENABLED'.freeze
10
- ENV_ANALYTICS_ENABLED = 'DD_TRACE_SIDEKIQ_ANALYTICS_ENABLED'.freeze
11
- ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_SIDEKIQ_ANALYTICS_SAMPLE_RATE'.freeze
12
- ENV_TAG_JOB_ARGS = 'DD_SIDEKIQ_TAG_JOB_ARGS'.freeze
13
- SERVICE_NAME = 'sidekiq'.freeze
14
- SPAN_PUSH = 'sidekiq.push'.freeze
15
- SPAN_JOB = 'sidekiq.job'.freeze
16
- SPAN_JOB_FETCH = 'sidekiq.job_fetch'.freeze
17
- SPAN_REDIS_INFO = 'sidekiq.redis_info'.freeze
18
- SPAN_HEARTBEAT = 'sidekiq.heartbeat'.freeze
19
- SPAN_SCHEDULED_PUSH = 'sidekiq.scheduled_push'.freeze
20
- SPAN_SCHEDULED_WAIT = 'sidekiq.scheduled_poller_wait'.freeze
21
- SPAN_STOP = 'sidekiq.stop'.freeze
22
- TAG_JOB_DELAY = 'sidekiq.job.delay'.freeze
23
- TAG_JOB_ID = 'sidekiq.job.id'.freeze
24
- TAG_JOB_QUEUE = 'sidekiq.job.queue'.freeze
25
- TAG_JOB_RETRY = 'sidekiq.job.retry'.freeze
26
- TAG_JOB_RETRY_COUNT = 'sidekiq.job.retry_count'.freeze
27
- TAG_JOB_WRAPPER = 'sidekiq.job.wrapper'.freeze
28
- TAG_JOB_ARGS = 'sidekiq.job.args'.freeze
29
- TAG_COMPONENT = 'sidekiq'.freeze
30
- TAG_OPERATION_PUSH = 'push'.freeze
31
- TAG_OPERATION_JOB = 'job'.freeze
32
- TAG_OPERATION_JOB_FETCH = 'job_fetch'.freeze
33
- TAG_OPERATION_REDIS_INFO = 'redis_info'.freeze
34
- TAG_OPERATION_HEARTBEAT = 'heartbeat'.freeze
35
- TAG_OPERATION_SCHEDULED_PUSH = 'scheduled_push'.freeze
36
- TAG_OPERATION_SCHEDULED_WAIT = 'scheduled_poller_wait'.freeze
37
- TAG_OPERATION_STOP = 'stop'.freeze
10
+ CLIENT_SERVICE_NAME = 'sidekiq-client'
11
+ ENV_ENABLED = 'DD_TRACE_SIDEKIQ_ENABLED'
12
+ ENV_ANALYTICS_ENABLED = 'DD_TRACE_SIDEKIQ_ANALYTICS_ENABLED'
13
+ ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_SIDEKIQ_ANALYTICS_SAMPLE_RATE'
14
+ ENV_TAG_JOB_ARGS = 'DD_SIDEKIQ_TAG_JOB_ARGS'
15
+ SERVICE_NAME = 'sidekiq'
16
+ SPAN_PUSH = 'sidekiq.push'
17
+ SPAN_JOB = 'sidekiq.job'
18
+ SPAN_JOB_FETCH = 'sidekiq.job_fetch'
19
+ SPAN_REDIS_INFO = 'sidekiq.redis_info'
20
+ SPAN_HEARTBEAT = 'sidekiq.heartbeat'
21
+ SPAN_SCHEDULED_PUSH = 'sidekiq.scheduled_push'
22
+ SPAN_SCHEDULED_WAIT = 'sidekiq.scheduled_poller_wait'
23
+ SPAN_STOP = 'sidekiq.stop'
24
+ TAG_JOB_DELAY = 'sidekiq.job.delay'
25
+ TAG_JOB_ID = 'sidekiq.job.id'
26
+ TAG_JOB_QUEUE = 'sidekiq.job.queue'
27
+ TAG_JOB_RETRY = 'sidekiq.job.retry'
28
+ TAG_JOB_RETRY_COUNT = 'sidekiq.job.retry_count'
29
+ TAG_JOB_WRAPPER = 'sidekiq.job.wrapper'
30
+ TAG_JOB_ARGS = 'sidekiq.job.args'
31
+ TAG_COMPONENT = 'sidekiq'
32
+ TAG_OPERATION_PUSH = 'push'
33
+ TAG_OPERATION_JOB = 'job'
34
+ TAG_OPERATION_JOB_FETCH = 'job_fetch'
35
+ TAG_OPERATION_REDIS_INFO = 'redis_info'
36
+ TAG_OPERATION_HEARTBEAT = 'heartbeat'
37
+ TAG_OPERATION_SCHEDULED_PUSH = 'scheduled_push'
38
+ TAG_OPERATION_SCHEDULED_WAIT = 'scheduled_poller_wait'
39
+ TAG_OPERATION_STOP = 'stop'
38
40
  end
39
41
  end
40
42
  end
@@ -14,23 +14,25 @@ module Datadog
14
14
  }.freeze
15
15
 
16
16
  option :enabled do |o|
17
- o.default { env_to_bool(Ext::ENV_ENABLED, true) }
18
- o.lazy
17
+ o.type :bool
18
+ o.env Ext::ENV_ENABLED
19
+ o.default true
19
20
  end
20
21
 
21
22
  option :analytics_enabled do |o|
22
- o.default { env_to_bool(Ext::ENV_ANALYTICS_ENABLED, nil) }
23
- o.lazy
23
+ o.type :bool, nilable: true
24
+ o.env Ext::ENV_ANALYTICS_ENABLED
24
25
  end
25
26
 
26
27
  option :analytics_sample_rate do |o|
27
- o.default { env_to_float(Ext::ENV_ANALYTICS_SAMPLE_RATE, 1.0) }
28
- o.lazy
28
+ o.type :float
29
+ o.env Ext::ENV_ANALYTICS_SAMPLE_RATE
30
+ o.default 1.0
29
31
  end
30
32
 
31
- option :distributed_tracing, default: true
32
- option :headers, default: DEFAULT_HEADERS
33
- option :resource_script_names, default: false
33
+ option :distributed_tracing, default: true, type: :bool
34
+ option :headers, default: DEFAULT_HEADERS, type: :hash
35
+ option :resource_script_names, default: false, type: :bool
34
36
 
35
37
  option :service_name
36
38
  end
@@ -19,23 +19,6 @@ module Datadog
19
19
  env[Ext::RACK_ENV_SINATRA_REQUEST_SPAN] = span
20
20
  end
21
21
 
22
- def request_header_tags(env, headers)
23
- headers ||= []
24
-
25
- {}.tap do |result|
26
- headers.each do |header|
27
- rack_header = header_to_rack_header(header)
28
- if env.key?(rack_header)
29
- result[Tracing::Metadata::Ext::HTTP::RequestHeaders.to_tag(header)] = env[rack_header]
30
- end
31
- end
32
- end
33
- end
34
-
35
- def header_to_rack_header(name)
36
- "HTTP_#{name.to_s.upcase.gsub(/[-\s]/, '_')}"
37
- end
38
-
39
22
  def route_path(env, use_script_names: Datadog.configuration.tracing[:sinatra][:resource_script_names])
40
23
  return unless env['sinatra.route']
41
24
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Tracing
3
5
  module Contrib
@@ -5,27 +7,27 @@ module Datadog
5
7
  # Sinatra integration constants
6
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
7
9
  module Ext
8
- ENV_ENABLED = 'DD_TRACE_SINATRA_ENABLED'.freeze
9
- ENV_ANALYTICS_ENABLED = 'DD_TRACE_SINATRA_ANALYTICS_ENABLED'.freeze
10
- ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_SINATRA_ANALYTICS_SAMPLE_RATE'.freeze
11
- RACK_ENV_SINATRA_REQUEST_SPAN = 'datadog.sinatra_request_span'.freeze
12
- SPAN_RENDER_TEMPLATE = 'sinatra.render_template'.freeze
13
- SPAN_REQUEST = 'sinatra.request'.freeze
14
- SPAN_ROUTE = 'sinatra.route'.freeze
15
- TAG_APP_NAME = 'sinatra.app.name'.freeze
16
- TAG_COMPONENT = 'sinatra'.freeze
17
- TAG_OPERATION_RENDER_TEMPLATE = 'render_template'.freeze
18
- TAG_OPERATION_REQUEST = 'request'.freeze
19
- TAG_OPERATION_ROUTE = 'route'.freeze
20
- TAG_ROUTE_PATH = 'sinatra.route.path'.freeze
21
- TAG_SCRIPT_NAME = 'sinatra.script_name'.freeze
22
- TAG_TEMPLATE_ENGINE = 'sinatra.template_engine'.freeze
23
- TAG_TEMPLATE_NAME = 'sinatra.template_name'.freeze
10
+ ENV_ENABLED = 'DD_TRACE_SINATRA_ENABLED'
11
+ ENV_ANALYTICS_ENABLED = 'DD_TRACE_SINATRA_ANALYTICS_ENABLED'
12
+ ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_SINATRA_ANALYTICS_SAMPLE_RATE'
13
+ RACK_ENV_SINATRA_REQUEST_SPAN = 'datadog.sinatra_request_span'
14
+ SPAN_RENDER_TEMPLATE = 'sinatra.render_template'
15
+ SPAN_REQUEST = 'sinatra.request'
16
+ SPAN_ROUTE = 'sinatra.route'
17
+ TAG_APP_NAME = 'sinatra.app.name'
18
+ TAG_COMPONENT = 'sinatra'
19
+ TAG_OPERATION_RENDER_TEMPLATE = 'render_template'
20
+ TAG_OPERATION_REQUEST = 'request'
21
+ TAG_OPERATION_ROUTE = 'route'
22
+ TAG_ROUTE_PATH = 'sinatra.route.path'
23
+ TAG_SCRIPT_NAME = 'sinatra.script_name'
24
+ TAG_TEMPLATE_ENGINE = 'sinatra.template_engine'
25
+ TAG_TEMPLATE_NAME = 'sinatra.template_name'
24
26
 
25
27
  # === Deprecated: To be removed ===
26
- RACK_ENV_REQUEST_SPAN = 'datadog.sinatra_request_span'.freeze
27
- RACK_ENV_MIDDLEWARE_START_TIME = 'datadog.sinatra_middleware_start_time'.freeze
28
- RACK_ENV_MIDDLEWARE_TRACED = 'datadog.sinatra_middleware_traced'.freeze
28
+ RACK_ENV_REQUEST_SPAN = 'datadog.sinatra_request_span'
29
+ RACK_ENV_MIDDLEWARE_START_TIME = 'datadog.sinatra_middleware_start_time'
30
+ RACK_ENV_MIDDLEWARE_TRACED = 'datadog.sinatra_middleware_traced'
29
31
  # === Deprecated: To be removed ===
30
32
  end
31
33
  end
@@ -3,9 +3,9 @@
3
3
  require_relative '../../metadata/ext'
4
4
  require_relative '../analytics'
5
5
  require_relative '../rack/ext'
6
+ require_relative '../rack/header_tagging'
6
7
  require_relative 'env'
7
8
  require_relative 'ext'
8
- require_relative 'headers'
9
9
 
10
10
  module Datadog
11
11
  module Tracing
@@ -20,8 +20,6 @@ module Datadog
20
20
 
21
21
  # rubocop:disable Metrics/AbcSize
22
22
  # rubocop:disable Metrics/MethodLength
23
- # rubocop:disable Metrics/CyclomaticComplexity
24
- # rubocop:disable Metrics/PerceivedComplexity
25
23
  def call(env)
26
24
  # Set the trace context (e.g. distributed tracing)
27
25
  if configuration[:distributed_tracing] && Tracing.active_trace.nil?
@@ -45,9 +43,7 @@ module Datadog
45
43
 
46
44
  response = @app.call(env)
47
45
  ensure
48
- Sinatra::Env.request_header_tags(env, configuration[:headers][:request]).each do |name, value|
49
- span.set_tag(name, value) if span.get_tag(name).nil?
50
- end
46
+ Contrib::Rack::HeaderTagging.tag_request_headers(span, env, configuration)
51
47
 
52
48
  span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
53
49
  span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_REQUEST)
@@ -85,12 +81,7 @@ module Datadog
85
81
  end
86
82
 
87
83
  if (headers = response[1])
88
- Sinatra::Headers.response_header_tags(
89
- headers,
90
- configuration[:headers][:response]
91
- ).each do |name, value|
92
- span.set_tag(name, value) if span.get_tag(name).nil?
93
- end
84
+ Contrib::Rack::HeaderTagging.tag_response_headers(span, headers, configuration)
94
85
  end
95
86
  end
96
87
 
@@ -104,8 +95,6 @@ module Datadog
104
95
  end
105
96
  # rubocop:enable Metrics/AbcSize
106
97
  # rubocop:enable Metrics/MethodLength
107
- # rubocop:enable Metrics/CyclomaticComplexity
108
- # rubocop:enable Metrics/PerceivedComplexity
109
98
 
110
99
  private
111
100
 
@@ -11,23 +11,29 @@ module Datadog
11
11
  # Default settings for the Shoryuken integration
12
12
  class Settings < Contrib::Configuration::Settings
13
13
  option :enabled do |o|
14
- o.default { env_to_bool(Ext::ENV_ENABLED, true) }
15
- o.lazy
14
+ o.type :bool
15
+ o.env Ext::ENV_ENABLED
16
+ o.default true
16
17
  end
17
18
 
18
19
  option :analytics_enabled do |o|
19
- o.default { env_to_bool(Ext::ENV_ANALYTICS_ENABLED, false) }
20
- o.lazy
20
+ o.type :bool
21
+ o.env Ext::ENV_ANALYTICS_ENABLED
22
+ o.default false
21
23
  end
22
24
 
23
25
  option :analytics_sample_rate do |o|
24
- o.default { env_to_float(Ext::ENV_ANALYTICS_SAMPLE_RATE, 1.0) }
25
- o.lazy
26
+ o.type :float
27
+ o.env Ext::ENV_ANALYTICS_SAMPLE_RATE
28
+ o.default 1.0
26
29
  end
27
30
 
28
31
  option :service_name
29
- option :error_handler, default: Tracing::SpanOperation::Events::DEFAULT_ON_ERROR
30
- option :tag_body, default: false
32
+ option :error_handler do |o|
33
+ o.type :proc
34
+ o.experimental_default_proc(&Tracing::SpanOperation::Events::DEFAULT_ON_ERROR)
35
+ end
36
+ option :tag_body, default: false, type: :bool
31
37
  end
32
38
  end
33
39
  end
@@ -18,6 +18,7 @@ module Datadog
18
18
  TAG_COMPONENT = 'sneakers'
19
19
  TAG_OPERATION_JOB = 'job'
20
20
  TAG_MESSAGING_SYSTEM = 'rabbitmq'
21
+ TAG_RABBITMQ_ROUTING_KEY = 'messaging.rabbitmq.routing_key'
21
22
  end
22
23
  end
23
24
  end
@@ -37,7 +37,7 @@ module Datadog
37
37
 
38
38
  request_span.resource = @app.to_proc.binding.eval('self.class').to_s
39
39
  request_span.set_tag(Ext::TAG_JOB_ROUTING_KEY, delivery_info.routing_key)
40
- request_span.set_tag(Contrib::Ext::Messaging::TAG_RABBITMQ_ROUTING_KEY, delivery_info.routing_key)
40
+ request_span.set_tag(Ext::TAG_RABBITMQ_ROUTING_KEY, delivery_info.routing_key)
41
41
  request_span.set_tag(Ext::TAG_JOB_QUEUE, delivery_info.consumer.queue.name)
42
42
 
43
43
  request_span.set_tag(Ext::TAG_JOB_BODY, deserialized_msg) if configuration[:tag_body]
@@ -1,27 +1,91 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'ext'
4
+
3
5
  module Datadog
4
6
  module Tracing
5
7
  module Contrib
6
8
  # Contains methods for fetching values according to span attributes schema
7
9
  module SpanAttributeSchema
8
- module_function
10
+ REFLEXIVE_SOURCES = [Tracing::Metadata::Ext::TAG_PEER_SERVICE].freeze
11
+ NO_SOURCE = [].freeze
9
12
 
10
- def fetch_service_name(env, default)
13
+ def self.fetch_service_name(env, default)
11
14
  ENV.fetch(env) do
12
- if Datadog.configuration.tracing.span_attribute_schema ==
13
- Tracing::Configuration::Ext::SpanAttributeSchema::VERSION_ONE
14
- Datadog.configuration.service
15
- else
16
- default
15
+ if Datadog.configuration.tracing.contrib.global_default_service_name.enabled
16
+ return Datadog.configuration.service
17
17
  end
18
+
19
+ default
18
20
  end
19
21
  end
20
22
 
21
- def default_span_attribute_schema?
22
- Datadog.configuration.tracing.span_attribute_schema ==
23
- Tracing::Configuration::Ext::SpanAttributeSchema::DEFAULT_VERSION
23
+ def self.set_peer_service!(span, sources)
24
+ # Acquire all peer.service values as well as any potential remapping
25
+ peer_service_val, peer_service_source = set_peer_service_from_source(span, sources)
26
+ remap_val = Datadog.configuration.tracing.contrib.peer_service_mapping[peer_service_val]
27
+
28
+ # Only continue to setting peer.service if actual source is found
29
+ return false unless peer_service_source
30
+
31
+ span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_PEER_SERVICE_SOURCE, peer_service_source)
32
+
33
+ # Set peer.service to remapped value if found otherwise normally set peer.service
34
+ if remap_val
35
+ span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, remap_val)
36
+ span.set_tag(Tracing::Contrib::Ext::Metadata::TAG_PEER_SERVICE_REMAP, peer_service_val)
37
+ else
38
+ span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, peer_service_val)
39
+ end
40
+ true
41
+ end
42
+
43
+ # set_peer_service_from_source: Implements the extraction logic to determine the peer.service value
44
+ # based on the list of source tags passed as a parameter.
45
+ #
46
+ # If no values are found, it checks the default list for all spans before returning false for no result
47
+ # Sets the source of where the information for peer.service was extracted from
48
+ # Returns a peer.service value if successfully set or not
49
+ def self.set_peer_service_from_source(span, sources = [])
50
+ # Filter out sources based on existence of peer.service tag
51
+ sources = filter_peer_service_sources(span, sources)
52
+
53
+ # Find a possible peer.service source from the list of source tags passed in
54
+ sources.each do |source|
55
+ source_val = span.get_tag(source)
56
+ next unless not_empty_tag?(source_val)
57
+
58
+ return source_val, source
59
+ end
60
+ false
24
61
  end
62
+
63
+ private_class_method :set_peer_service_from_source
64
+
65
+ # filter_peer_service_sources: returns filtered sources based on existence of peer.service tag
66
+ # If peer.service exists, we do not read from any other source rather use peer.service as source
67
+ # This is to prevent overwriting of pre-existing peer.service tags
68
+ def self.filter_peer_service_sources(span, sources)
69
+ ps = span.get_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE)
70
+ # Do not override existing peer.service tag if it exists based on schema version
71
+ return REFLEXIVE_SOURCES if not_empty_tag?(ps)
72
+
73
+ # Check that peer.service is only set on spankind client/producer spans
74
+ if (span.get_tag(Tracing::Metadata::Ext::TAG_KIND) == Tracing::Metadata::Ext::SpanKind::TAG_CLIENT) ||
75
+ (span.get_tag(Tracing::Metadata::Ext::TAG_KIND) == Tracing::Metadata::Ext::SpanKind::TAG_PRODUCER)
76
+ return sources
77
+ end
78
+
79
+ NO_SOURCE
80
+ end
81
+
82
+ private_class_method :filter_peer_service_sources
83
+
84
+ def self.not_empty_tag?(tag)
85
+ tag && (tag != '')
86
+ end
87
+
88
+ private_class_method :not_empty_tag?
25
89
  end
26
90
  end
27
91
  end
@@ -12,18 +12,21 @@ module Datadog
12
12
  # @public_api
13
13
  class Settings < Contrib::Configuration::Settings
14
14
  option :enabled do |o|
15
- o.default { env_to_bool(Ext::ENV_ENABLED, true) }
16
- o.lazy
15
+ o.type :bool
16
+ o.env Ext::ENV_ENABLED
17
+ o.default true
17
18
  end
18
19
 
19
20
  option :analytics_enabled do |o|
20
- o.default { env_to_bool(Ext::ENV_ANALYTICS_ENABLED, false) }
21
- o.lazy
21
+ o.type :bool
22
+ o.env Ext::ENV_ANALYTICS_ENABLED
23
+ o.default false
22
24
  end
23
25
 
24
26
  option :analytics_sample_rate do |o|
25
- o.default { env_to_float(Ext::ENV_ANALYTICS_SAMPLE_RATE, 1.0) }
26
- o.lazy
27
+ o.type :float
28
+ o.env Ext::ENV_ANALYTICS_SAMPLE_RATE
29
+ o.default 1.0
27
30
  end
28
31
  end
29
32
  end
@@ -12,18 +12,21 @@ module Datadog
12
12
  # @public_api
13
13
  class Settings < Contrib::Configuration::Settings
14
14
  option :enabled do |o|
15
- o.default { env_to_bool(Ext::ENV_ENABLED, true) }
16
- o.lazy
15
+ o.type :bool
16
+ o.env Ext::ENV_ENABLED
17
+ o.default true
17
18
  end
18
19
 
19
20
  option :analytics_enabled do |o|
20
- o.default { env_to_bool(Ext::ENV_ANALYTICS_ENABLED, false) }
21
- o.lazy
21
+ o.type :bool
22
+ o.env Ext::ENV_ANALYTICS_ENABLED
23
+ o.default false
22
24
  end
23
25
 
24
26
  option :analytics_sample_rate do |o|
25
- o.default { env_to_float(Ext::ENV_ANALYTICS_SAMPLE_RATE, 1.0) }
26
- o.lazy
27
+ o.type :float
28
+ o.env Ext::ENV_ANALYTICS_SAMPLE_RATE
29
+ o.default 1.0
27
30
  end
28
31
 
29
32
  option :service_name
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Tracing
3
5
  module Contrib
@@ -5,19 +7,19 @@ module Datadog
5
7
  # SuckerPunch integration constants
6
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
7
9
  module Ext
8
- ENV_ENABLED = 'DD_TRACE_SUCKER_PUNCH_ENABLED'.freeze
9
- ENV_ANALYTICS_ENABLED = 'DD_TRACE_SUCKER_PUNCH_ANALYTICS_ENABLED'.freeze
10
- ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_SUCKER_PUNCH_ANALYTICS_SAMPLE_RATE'.freeze
11
- SERVICE_NAME = 'sucker_punch'.freeze
12
- SPAN_PERFORM = 'sucker_punch.perform'.freeze
13
- SPAN_PERFORM_ASYNC = 'sucker_punch.perform_async'.freeze
14
- SPAN_PERFORM_IN = 'sucker_punch.perform_in'.freeze
15
- TAG_PERFORM_IN = 'sucker_punch.perform_in'.freeze
16
- TAG_QUEUE = 'sucker_punch.queue'.freeze
17
- TAG_COMPONENT = 'sucker_punch'.freeze
18
- TAG_OPERATION_PERFORM = 'perform'.freeze
19
- TAG_OPERATION_PERFORM_ASYNC = 'perform_async'.freeze
20
- TAG_OPERATION_PERFORM_IN = 'perform_in'.freeze
10
+ ENV_ENABLED = 'DD_TRACE_SUCKER_PUNCH_ENABLED'
11
+ ENV_ANALYTICS_ENABLED = 'DD_TRACE_SUCKER_PUNCH_ANALYTICS_ENABLED'
12
+ ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_SUCKER_PUNCH_ANALYTICS_SAMPLE_RATE'
13
+ SERVICE_NAME = 'sucker_punch'
14
+ SPAN_PERFORM = 'sucker_punch.perform'
15
+ SPAN_PERFORM_ASYNC = 'sucker_punch.perform_async'
16
+ SPAN_PERFORM_IN = 'sucker_punch.perform_in'
17
+ TAG_PERFORM_IN = 'sucker_punch.perform_in'
18
+ TAG_QUEUE = 'sucker_punch.queue'
19
+ TAG_COMPONENT = 'sucker_punch'
20
+ TAG_OPERATION_PERFORM = 'perform'
21
+ TAG_OPERATION_PERFORM_ASYNC = 'perform_async'
22
+ TAG_OPERATION_PERFORM_IN = 'perform_in'
21
23
  end
22
24
  end
23
25
  end
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Tracing
3
5
  module Contrib
4
6
  module Utils
5
7
  # Common database-related utility functions.
6
8
  module Database
7
- VENDOR_DEFAULT = 'defaultdb'.freeze
8
- VENDOR_POSTGRES = 'postgres'.freeze
9
- VENDOR_SQLITE = 'sqlite'.freeze
9
+ VENDOR_DEFAULT = 'defaultdb'
10
+ VENDOR_POSTGRES = 'postgres'
11
+ VENDOR_SQLITE = 'sqlite'
10
12
 
11
13
  module_function
12
14
 
@@ -58,6 +58,7 @@ require_relative 'contrib/kafka/integration'
58
58
  require_relative 'contrib/lograge/integration'
59
59
  require_relative 'contrib/mongodb/integration'
60
60
  require_relative 'contrib/mysql2/integration'
61
+ require_relative 'contrib/opensearch/integration'
61
62
  require_relative 'contrib/pg/integration'
62
63
  require_relative 'contrib/presto/integration'
63
64
  require_relative 'contrib/qless/integration'
@@ -23,7 +23,6 @@ module Datadog
23
23
  :span_resource,
24
24
  :span_service,
25
25
  :span_type,
26
- :trace_id,
27
26
  :trace_name,
28
27
  :trace_resource,
29
28
  :trace_service,
@@ -65,22 +64,20 @@ module Datadog
65
64
  attributes << "#{LOG_ATTR_ENV}=#{env}" unless env.nil?
66
65
  attributes << "#{LOG_ATTR_SERVICE}=#{service}"
67
66
  attributes << "#{LOG_ATTR_VERSION}=#{version}" unless version.nil?
68
- attributes << "#{LOG_ATTR_TRACE_ID}=#{logging_trace_id}"
67
+ attributes << "#{LOG_ATTR_TRACE_ID}=#{trace_id}"
69
68
  attributes << "#{LOG_ATTR_SPAN_ID}=#{span_id}"
70
69
  attributes.join(' ')
71
70
  end
72
71
  end
73
72
 
74
- private
75
-
76
- def logging_trace_id
77
- @logging_trace_id ||=
78
- if Datadog.configuration.tracing.trace_id_128_bit_logging_enabled &&
79
- !Tracing::Utils::TraceId.to_high_order(@trace_id).zero?
80
- Kernel.format('%032x', trace_id)
81
- else
82
- Tracing::Utils::TraceId.to_low_order(@trace_id)
83
- end
73
+ # DEV-2.0: This public method was returning an Integer, but with 128 bit trace id it would return a String.
74
+ def trace_id
75
+ if Datadog.configuration.tracing.trace_id_128_bit_logging_enabled &&
76
+ !Tracing::Utils::TraceId.to_high_order(@trace_id).zero?
77
+ Kernel.format('%032x', @trace_id)
78
+ else
79
+ Tracing::Utils::TraceId.to_low_order(@trace_id)
80
+ end
84
81
  end
85
82
  end
86
83
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Tracing
3
5
  module Diagnostics
@@ -7,25 +9,25 @@ module Datadog
7
9
  module Health
8
10
  # Metrics
9
11
  module Metrics
10
- METRIC_API_ERRORS = 'datadog.tracer.api.errors'.freeze
11
- METRIC_API_REQUESTS = 'datadog.tracer.api.requests'.freeze
12
- METRIC_API_RESPONSES = 'datadog.tracer.api.responses'.freeze
13
- METRIC_ERROR_CONTEXT_OVERFLOW = 'datadog.tracer.error.context_overflow'.freeze
14
- METRIC_ERROR_INSTRUMENTATION_PATCH = 'datadog.tracer.error.instrumentation_patch'.freeze
15
- METRIC_ERROR_SPAN_FINISH = 'datadog.tracer.error.span_finish'.freeze
16
- METRIC_ERROR_UNFINISHED_SPANS = 'datadog.tracer.error.unfinished_spans'.freeze
17
- METRIC_INSTRUMENTATION_PATCHED = 'datadog.tracer.instrumentation_patched'.freeze
18
- METRIC_QUEUE_ACCEPTED = 'datadog.tracer.queue.accepted'.freeze
19
- METRIC_QUEUE_ACCEPTED_LENGTHS = 'datadog.tracer.queue.accepted_lengths'.freeze
20
- METRIC_QUEUE_DROPPED = 'datadog.tracer.queue.dropped'.freeze
21
- METRIC_QUEUE_LENGTH = 'datadog.tracer.queue.length'.freeze
22
- METRIC_QUEUE_MAX_LENGTH = 'datadog.tracer.queue.max_length'.freeze
23
- METRIC_QUEUE_SPANS = 'datadog.tracer.queue.spans'.freeze
24
- METRIC_SAMPLING_SERVICE_CACHE_LENGTH = 'datadog.tracer.sampling.service_cache_length'.freeze
25
- METRIC_TRACES_FILTERED = 'datadog.tracer.traces.filtered'.freeze
26
- METRIC_TRANSPORT_CHUNKED = 'datadog.tracer.transport.chunked'.freeze
27
- METRIC_TRANSPORT_TRACE_TOO_LARGE = 'datadog.tracer.transport.trace_too_large'.freeze
28
- METRIC_WRITER_CPU_TIME = 'datadog.tracer.writer.cpu_time'.freeze
12
+ METRIC_API_ERRORS = 'datadog.tracer.api.errors'
13
+ METRIC_API_REQUESTS = 'datadog.tracer.api.requests'
14
+ METRIC_API_RESPONSES = 'datadog.tracer.api.responses'
15
+ METRIC_ERROR_CONTEXT_OVERFLOW = 'datadog.tracer.error.context_overflow'
16
+ METRIC_ERROR_INSTRUMENTATION_PATCH = 'datadog.tracer.error.instrumentation_patch'
17
+ METRIC_ERROR_SPAN_FINISH = 'datadog.tracer.error.span_finish'
18
+ METRIC_ERROR_UNFINISHED_SPANS = 'datadog.tracer.error.unfinished_spans'
19
+ METRIC_INSTRUMENTATION_PATCHED = 'datadog.tracer.instrumentation_patched'
20
+ METRIC_QUEUE_ACCEPTED = 'datadog.tracer.queue.accepted'
21
+ METRIC_QUEUE_ACCEPTED_LENGTHS = 'datadog.tracer.queue.accepted_lengths'
22
+ METRIC_QUEUE_DROPPED = 'datadog.tracer.queue.dropped'
23
+ METRIC_QUEUE_LENGTH = 'datadog.tracer.queue.length'
24
+ METRIC_QUEUE_MAX_LENGTH = 'datadog.tracer.queue.max_length'
25
+ METRIC_QUEUE_SPANS = 'datadog.tracer.queue.spans'
26
+ METRIC_SAMPLING_SERVICE_CACHE_LENGTH = 'datadog.tracer.sampling.service_cache_length'
27
+ METRIC_TRACES_FILTERED = 'datadog.tracer.traces.filtered'
28
+ METRIC_TRANSPORT_CHUNKED = 'datadog.tracer.transport.chunked'
29
+ METRIC_TRANSPORT_TRACE_TOO_LARGE = 'datadog.tracer.transport.trace_too_large'
30
+ METRIC_WRITER_CPU_TIME = 'datadog.tracer.writer.cpu_time'
29
31
  end
30
32
  end
31
33
  end
@@ -30,8 +30,8 @@ module Datadog
30
30
  return if digest.nil?
31
31
 
32
32
  # DEV: We need these to be hex encoded
33
- data[@trace_id_key] = digest.trace_id.to_s(16)
34
- data[@span_id_key] = digest.span_id.to_s(16)
33
+ data[@trace_id_key] = format('%032x', digest.trace_id)
34
+ data[@span_id_key] = format('%016x', digest.span_id)
35
35
 
36
36
  if digest.trace_sampling_priority
37
37
  sampling_priority = Helpers.clamp_sampling_priority(
@@ -26,7 +26,7 @@ module Datadog
26
26
  return if digest.nil?
27
27
 
28
28
  # DEV: We need these to be hex encoded
29
- value = "#{digest.trace_id.to_s(16)}-#{digest.span_id.to_s(16)}"
29
+ value = "#{format('%032x', digest.trace_id)}-#{format('%016x', digest.span_id)}"
30
30
 
31
31
  if digest.trace_sampling_priority
32
32
  sampling_priority = Helpers.clamp_sampling_priority(