ddtrace 1.12.1 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +109 -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/base.rb +5 -5
  56. data/lib/datadog/core/configuration/components.rb +6 -1
  57. data/lib/datadog/core/configuration/ext.rb +7 -5
  58. data/lib/datadog/core/configuration/option.rb +269 -19
  59. data/lib/datadog/core/configuration/option_definition.rb +76 -11
  60. data/lib/datadog/core/configuration/options.rb +22 -10
  61. data/lib/datadog/core/configuration/settings.rb +116 -61
  62. data/lib/datadog/core/environment/ext.rb +13 -11
  63. data/lib/datadog/core/environment/yjit.rb +58 -0
  64. data/lib/datadog/core/git/ext.rb +24 -22
  65. data/lib/datadog/core/logging/ext.rb +3 -1
  66. data/lib/datadog/core/metrics/ext.rb +7 -5
  67. data/lib/datadog/core/remote/client/capabilities.rb +5 -0
  68. data/lib/datadog/core/remote/client.rb +3 -0
  69. data/lib/datadog/core/remote/component.rb +25 -34
  70. data/lib/datadog/core/remote/configuration/content.rb +28 -1
  71. data/lib/datadog/core/remote/configuration/repository.rb +3 -1
  72. data/lib/datadog/core/remote/ext.rb +1 -1
  73. data/lib/datadog/core/remote/negotiation.rb +17 -4
  74. data/lib/datadog/core/runtime/ext.rb +22 -12
  75. data/lib/datadog/core/runtime/metrics.rb +43 -0
  76. data/lib/datadog/core/telemetry/client.rb +12 -2
  77. data/lib/datadog/core/telemetry/emitter.rb +4 -2
  78. data/lib/datadog/core/telemetry/event.rb +19 -4
  79. data/lib/datadog/core/telemetry/ext.rb +4 -1
  80. data/lib/datadog/core/telemetry/heartbeat.rb +2 -4
  81. data/lib/datadog/core/telemetry/http/ext.rb +10 -8
  82. data/lib/datadog/core/telemetry/http/transport.rb +1 -0
  83. data/lib/datadog/core/telemetry/v2/app_client_configuration_change.rb +41 -0
  84. data/lib/datadog/core/telemetry/v2/request.rb +29 -0
  85. data/lib/datadog/core/transport/http/client.rb +1 -1
  86. data/lib/datadog/core/transport/http/config.rb +10 -0
  87. data/lib/datadog/core/utils/duration.rb +52 -0
  88. data/lib/datadog/core/utils/hash.rb +47 -0
  89. data/lib/datadog/core/utils/network.rb +1 -1
  90. data/lib/datadog/core/utils/safe_dup.rb +27 -20
  91. data/lib/datadog/core/utils.rb +1 -1
  92. data/lib/datadog/core/workers/async.rb +2 -2
  93. data/lib/datadog/kit/appsec/events.rb +139 -89
  94. data/lib/datadog/kit/identity.rb +80 -65
  95. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +3 -0
  96. data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -0
  97. data/lib/datadog/profiling/collectors/thread_context.rb +9 -2
  98. data/lib/datadog/profiling/component.rb +41 -9
  99. data/lib/datadog/profiling/exporter.rb +5 -1
  100. data/lib/datadog/profiling/flush.rb +9 -2
  101. data/lib/datadog/profiling/http_transport.rb +4 -1
  102. data/lib/datadog/profiling/load_native_extension.rb +7 -1
  103. data/lib/datadog/profiling.rb +11 -1
  104. data/lib/datadog/tracing/component.rb +58 -6
  105. data/lib/datadog/tracing/configuration/dynamic/option.rb +71 -0
  106. data/lib/datadog/tracing/configuration/dynamic.rb +64 -0
  107. data/lib/datadog/tracing/configuration/ext.rb +35 -32
  108. data/lib/datadog/tracing/configuration/http.rb +74 -0
  109. data/lib/datadog/tracing/configuration/settings.rb +106 -92
  110. data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +9 -6
  111. data/lib/datadog/tracing/contrib/action_cable/ext.rb +20 -18
  112. data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +9 -6
  113. data/lib/datadog/tracing/contrib/action_mailer/ext.rb +20 -18
  114. data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +8 -6
  115. data/lib/datadog/tracing/contrib/action_pack/ext.rb +10 -8
  116. data/lib/datadog/tracing/contrib/action_view/configuration/settings.rb +9 -6
  117. data/lib/datadog/tracing/contrib/action_view/ext.rb +12 -10
  118. data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +13 -7
  119. data/lib/datadog/tracing/contrib/active_job/ext.rb +25 -23
  120. data/lib/datadog/tracing/contrib/active_job/log_injection.rb +1 -1
  121. data/lib/datadog/tracing/contrib/active_job/patcher.rb +1 -1
  122. data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +9 -6
  123. data/lib/datadog/tracing/contrib/active_model_serializers/ext.rb +12 -10
  124. data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +9 -7
  125. data/lib/datadog/tracing/contrib/active_record/events/sql.rb +0 -8
  126. data/lib/datadog/tracing/contrib/active_record/ext.rb +17 -15
  127. data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +0 -5
  128. data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +9 -7
  129. data/lib/datadog/tracing/contrib/active_support/ext.rb +18 -16
  130. data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +14 -7
  131. data/lib/datadog/tracing/contrib/aws/ext.rb +37 -24
  132. data/lib/datadog/tracing/contrib/aws/instrumentation.rb +9 -5
  133. data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +3 -2
  134. data/lib/datadog/tracing/contrib/concurrent_ruby/ext.rb +4 -2
  135. data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +14 -7
  136. data/lib/datadog/tracing/contrib/dalli/ext.rb +19 -11
  137. data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +8 -6
  138. data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +13 -7
  139. data/lib/datadog/tracing/contrib/delayed_job/ext.rb +16 -14
  140. data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +14 -7
  141. data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +21 -15
  142. data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +8 -5
  143. data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +16 -9
  144. data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +43 -3
  145. data/lib/datadog/tracing/contrib/ethon/ext.rb +19 -11
  146. data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +0 -5
  147. data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +19 -10
  148. data/lib/datadog/tracing/contrib/excon/ext.rb +16 -8
  149. data/lib/datadog/tracing/contrib/excon/middleware.rb +20 -5
  150. data/lib/datadog/tracing/contrib/ext.rb +23 -1
  151. data/lib/datadog/tracing/contrib/extensions.rb +32 -0
  152. data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +20 -10
  153. data/lib/datadog/tracing/contrib/faraday/ext.rb +16 -8
  154. data/lib/datadog/tracing/contrib/faraday/middleware.rb +16 -5
  155. data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +8 -6
  156. data/lib/datadog/tracing/contrib/grape/ext.rb +16 -14
  157. data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +8 -6
  158. data/lib/datadog/tracing/contrib/graphql/ext.rb +7 -5
  159. data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +19 -9
  160. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +29 -20
  161. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +21 -20
  162. data/lib/datadog/tracing/contrib/grpc/ext.rb +16 -13
  163. data/lib/datadog/tracing/contrib/grpc/formatting.rb +127 -0
  164. data/lib/datadog/tracing/contrib/hanami/configuration/settings.rb +3 -2
  165. data/lib/datadog/tracing/contrib/hanami/ext.rb +10 -8
  166. data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +4 -7
  167. data/lib/datadog/tracing/contrib/http/configuration/settings.rb +33 -11
  168. data/lib/datadog/tracing/contrib/http/ext.rb +16 -9
  169. data/lib/datadog/tracing/contrib/http/instrumentation.rb +17 -5
  170. data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +33 -11
  171. data/lib/datadog/tracing/contrib/httpclient/ext.rb +17 -9
  172. data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +17 -5
  173. data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +33 -11
  174. data/lib/datadog/tracing/contrib/httprb/ext.rb +16 -9
  175. data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +17 -5
  176. data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +9 -6
  177. data/lib/datadog/tracing/contrib/kafka/ext.rb +42 -39
  178. data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +3 -2
  179. data/lib/datadog/tracing/contrib/lograge/ext.rb +3 -1
  180. data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +1 -0
  181. data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +14 -7
  182. data/lib/datadog/tracing/contrib/mongodb/ext.rb +20 -16
  183. data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +9 -5
  184. data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +17 -14
  185. data/lib/datadog/tracing/contrib/mysql2/ext.rb +15 -10
  186. data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +9 -5
  187. data/lib/datadog/tracing/contrib/opensearch/configuration/settings.rb +52 -0
  188. data/lib/datadog/tracing/contrib/opensearch/ext.rb +37 -0
  189. data/lib/datadog/tracing/contrib/opensearch/integration.rb +44 -0
  190. data/lib/datadog/tracing/contrib/opensearch/patcher.rb +128 -0
  191. data/lib/datadog/tracing/contrib/opensearch/quantize.rb +81 -0
  192. data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +17 -14
  193. data/lib/datadog/tracing/contrib/pg/ext.rb +22 -19
  194. data/lib/datadog/tracing/contrib/pg/instrumentation.rb +9 -5
  195. data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +14 -7
  196. data/lib/datadog/tracing/contrib/presto/ext.rb +25 -20
  197. data/lib/datadog/tracing/contrib/presto/instrumentation.rb +9 -5
  198. data/lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb +12 -10
  199. data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +12 -8
  200. data/lib/datadog/tracing/contrib/qless/ext.rb +14 -12
  201. data/lib/datadog/tracing/contrib/que/configuration/settings.rb +21 -12
  202. data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +9 -7
  203. data/lib/datadog/tracing/contrib/racecar/event.rb +0 -5
  204. data/lib/datadog/tracing/contrib/racecar/ext.rb +20 -18
  205. data/lib/datadog/tracing/contrib/rack/configuration/settings.rb +16 -12
  206. data/lib/datadog/tracing/contrib/rack/ext.rb +18 -16
  207. data/lib/datadog/tracing/contrib/rack/header_collection.rb +3 -0
  208. data/lib/datadog/tracing/contrib/rack/header_tagging.rb +53 -0
  209. data/lib/datadog/tracing/contrib/rack/middlewares.rb +8 -49
  210. data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +15 -11
  211. data/lib/datadog/tracing/contrib/rails/ext.rb +7 -5
  212. data/lib/datadog/tracing/contrib/rails/log_injection.rb +4 -10
  213. data/lib/datadog/tracing/contrib/rails/patcher.rb +10 -41
  214. data/lib/datadog/tracing/contrib/rails/railtie.rb +3 -3
  215. data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +12 -9
  216. data/lib/datadog/tracing/contrib/rake/ext.rb +14 -12
  217. data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +17 -9
  218. data/lib/datadog/tracing/contrib/redis/ext.rb +22 -15
  219. data/lib/datadog/tracing/contrib/redis/tags.rb +9 -5
  220. data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +13 -7
  221. data/lib/datadog/tracing/contrib/resque/ext.rb +9 -7
  222. data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +16 -9
  223. data/lib/datadog/tracing/contrib/rest_client/ext.rb +15 -8
  224. data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +20 -5
  225. data/lib/datadog/tracing/contrib/roda/configuration/settings.rb +9 -6
  226. data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +3 -2
  227. data/lib/datadog/tracing/contrib/semantic_logger/ext.rb +3 -1
  228. data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +1 -0
  229. data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +9 -6
  230. data/lib/datadog/tracing/contrib/sequel/ext.rb +10 -8
  231. data/lib/datadog/tracing/contrib/sequel/utils.rb +2 -7
  232. data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +14 -8
  233. data/lib/datadog/tracing/contrib/shoryuken/ext.rb +14 -12
  234. data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +18 -11
  235. data/lib/datadog/tracing/contrib/sidekiq/ext.rb +32 -30
  236. data/lib/datadog/tracing/contrib/sinatra/configuration/settings.rb +11 -9
  237. data/lib/datadog/tracing/contrib/sinatra/env.rb +0 -17
  238. data/lib/datadog/tracing/contrib/sinatra/ext.rb +21 -19
  239. data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +3 -14
  240. data/lib/datadog/tracing/contrib/sneakers/configuration/settings.rb +14 -8
  241. data/lib/datadog/tracing/contrib/sneakers/ext.rb +1 -0
  242. data/lib/datadog/tracing/contrib/sneakers/tracer.rb +1 -1
  243. data/lib/datadog/tracing/contrib/span_attribute_schema.rb +74 -10
  244. data/lib/datadog/tracing/contrib/stripe/configuration/settings.rb +9 -6
  245. data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +9 -6
  246. data/lib/datadog/tracing/contrib/sucker_punch/ext.rb +15 -13
  247. data/lib/datadog/tracing/contrib/utils/database.rb +5 -3
  248. data/lib/datadog/tracing/correlation.rb +9 -12
  249. data/lib/datadog/tracing/diagnostics/ext.rb +21 -19
  250. data/lib/datadog/tracing/distributed/b3_multi.rb +2 -2
  251. data/lib/datadog/tracing/distributed/b3_single.rb +1 -1
  252. data/lib/datadog/tracing/distributed/trace_context.rb +52 -17
  253. data/lib/datadog/tracing/metadata/ext.rb +9 -6
  254. data/lib/datadog/tracing/remote.rb +78 -0
  255. data/lib/datadog/tracing/sampling/rule_sampler.rb +29 -0
  256. data/lib/datadog/tracing/span_operation.rb +3 -15
  257. data/lib/datadog/tracing/trace_operation.rb +16 -3
  258. data/lib/datadog/tracing/trace_segment.rb +5 -2
  259. data/lib/datadog/tracing/tracer.rb +10 -1
  260. data/lib/ddtrace/transport/ext.rb +15 -9
  261. data/lib/ddtrace/transport/trace_formatter.rb +9 -0
  262. data/lib/ddtrace/version.rb +9 -12
  263. metadata +38 -10
  264. data/lib/datadog/tracing/contrib/sinatra/headers.rb +0 -35
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Datadog
4
+ module Tracing
5
+ module Contrib
6
+ module GRPC
7
+ module Formatting
8
+ VALUE_UNKNOWN = 'unknown'
9
+
10
+ # A class to extract GRPC span attributes from the GRPC implementing class method object.
11
+ class MethodObjectFormatter
12
+ # grpc_full_method is a string containing all the rpc method information (from the Protobuf definition)
13
+ # in a single string with the following format: /$package.$service/$method
14
+ attr_reader :grpc_full_method
15
+
16
+ # legacy_grpc_service is built using the Ruby GRPC service implementation package and class name instead
17
+ # of the rpc interface representation from Protobuf. It's kept for compatibility.
18
+ attr_reader :legacy_grpc_service
19
+
20
+ # legacy_grpc_method is built using the Ruby GRPC service implementation method name instead of the rpc
21
+ # interface representation from Protobuf. It's kept for compatibility.
22
+ attr_reader :legacy_grpc_method
23
+
24
+ # resource_name is used for the span resource name.
25
+ attr_reader :resource_name
26
+
27
+ def initialize(grpc_method_object)
28
+ @grpc_full_method = format_full_method(grpc_method_object)
29
+ @resource_name = format_resource_name(grpc_method_object)
30
+ @legacy_grpc_method = extract_legacy_grpc_method(grpc_method_object)
31
+ @legacy_grpc_service = extract_legacy_grpc_service(grpc_method_object)
32
+ end
33
+
34
+ private
35
+
36
+ def format_full_method(grpc_method_object)
37
+ service = extract_grpc_service(grpc_method_object)
38
+ method = extract_grpc_method(grpc_method_object)
39
+ "/#{service}/#{method}"
40
+ end
41
+
42
+ def extract_grpc_service(grpc_method_object)
43
+ owner = grpc_method_object.owner
44
+ return VALUE_UNKNOWN unless owner.instance_variable_defined?(:@service_name)
45
+
46
+ # Ruby protoc generated code includes this variable which directly contains the value from the original
47
+ # protobuf definition
48
+ owner.service_name.to_s
49
+ end
50
+
51
+ # extract_grpc_method attempts to find the original method name from the Protobuf file definition,
52
+ # since grpc gem forces the implementation method name to be in snake_case.
53
+ def extract_grpc_method(grpc_method_object)
54
+ owner = grpc_method_object.owner
55
+
56
+ return VALUE_UNKNOWN unless owner.instance_variable_defined?(:@rpc_descs)
57
+
58
+ method, = owner.rpc_descs.find do |k, _|
59
+ ::GRPC::GenericService.underscore(k.to_s) == grpc_method_object.name.to_s
60
+ end
61
+
62
+ return VALUE_UNKNOWN if method.nil?
63
+
64
+ method.to_s
65
+ end
66
+
67
+ def extract_legacy_grpc_service(grpc_method_object)
68
+ grpc_method_object.owner.to_s
69
+ end
70
+
71
+ def extract_legacy_grpc_method(grpc_method_object)
72
+ grpc_method_object.name
73
+ end
74
+
75
+ def format_resource_name(grpc_method_object)
76
+ grpc_method_object
77
+ .owner
78
+ .to_s
79
+ .downcase
80
+ .split('::')
81
+ .<<(grpc_method_object.name)
82
+ .join('.')
83
+ end
84
+ end
85
+
86
+ # A class to extract GRPC span attributes from the full method string.
87
+ class FullMethodStringFormatter
88
+ # grpc_full_method is a string containing all the rpc method information (from the Protobuf definition)
89
+ # in a single string with the following format: /$package.$service/$method
90
+ attr_reader :grpc_full_method
91
+
92
+ # resource_name is used for the span resource name.
93
+ attr_reader :resource_name
94
+
95
+ # rpc_service represents the $package.$service part of the grpc_full_method string.
96
+ attr_reader :rpc_service
97
+
98
+ def initialize(grpc_full_method)
99
+ @grpc_full_method = grpc_full_method
100
+ @resource_name = format_resource_name(grpc_full_method)
101
+ @rpc_service = extract_grpc_service(grpc_full_method)
102
+ end
103
+
104
+ private
105
+
106
+ def format_resource_name(grpc_full_method)
107
+ grpc_full_method
108
+ .downcase
109
+ .split('/')
110
+ .reject(&:empty?)
111
+ .join('.')
112
+ end
113
+
114
+ def extract_grpc_service(grpc_full_method)
115
+ parts = grpc_full_method.split('/')
116
+ if parts.length < 3
117
+ ''
118
+ else
119
+ parts[1]
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
@@ -11,8 +11,9 @@ module Datadog
11
11
  # Configuration for Hanami instrumentation
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
  end
18
19
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Tracing
3
5
  module Contrib
@@ -5,16 +7,16 @@ module Datadog
5
7
  # Hanami 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_HANAMI_ENABLED'.freeze
10
+ ENV_ENABLED = 'DD_TRACE_HANAMI_ENABLED'
9
11
 
10
- SPAN_ACTION = 'hanami.action'.freeze
11
- SPAN_ROUTING = 'hanami.routing'.freeze
12
- SPAN_RENDER = 'hanami.render'.freeze
12
+ SPAN_ACTION = 'hanami.action'
13
+ SPAN_ROUTING = 'hanami.routing'
14
+ SPAN_RENDER = 'hanami.render'
13
15
 
14
- TAG_COMPONENT = 'hanami'.freeze
15
- TAG_OPERATION_ACTION = 'action'.freeze
16
- TAG_OPERATION_ROUTING = 'routing'.freeze
17
- TAG_OPERATION_RENDER = 'render'.freeze
16
+ TAG_COMPONENT = 'hanami'
17
+ TAG_OPERATION_ACTION = 'action'
18
+ TAG_OPERATION_ROUTING = 'routing'
19
+ TAG_OPERATION_RENDER = 'render'
18
20
  end
19
21
  end
20
22
  end
@@ -10,7 +10,7 @@ module Datadog
10
10
  # For avoiding recursive traces.
11
11
  module CircuitBreaker
12
12
  def should_skip_tracing?(request)
13
- return true if datadog_http_request?(request)
13
+ return true if internal_request?(request)
14
14
 
15
15
  # we don't want a "shotgun" effect with two nested traces for one
16
16
  # logical get, and request is likely to call itself recursively
@@ -23,12 +23,9 @@ module Datadog
23
23
  # We don't want to trace our own call to the API (they use net/http)
24
24
  # TODO: We don't want this kind of soft-check on HTTP requests.
25
25
  # Remove this when transport implements its own "skip tracing" mechanism.
26
- def datadog_http_request?(request)
27
- if request[Datadog::Transport::Ext::HTTP::HEADER_META_TRACER_VERSION]
28
- true
29
- else
30
- false
31
- end
26
+ def internal_request?(request)
27
+ !!(request[Datadog::Transport::Ext::HTTP::HEADER_META_TRACER_VERSION] ||
28
+ request[Transport::Ext::HTTP::HEADER_DD_INTERNAL_UNTRACED_REQUEST])
32
29
  end
33
30
 
34
31
  def should_skip_distributed_tracing?(client_config)
@@ -12,21 +12,24 @@ 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
- option :distributed_tracing, default: true
32
+ option :distributed_tracing, default: true, type: :bool
30
33
 
31
34
  option :service_name do |o|
32
35
  o.default do
@@ -35,15 +38,34 @@ module Datadog
35
38
  Ext::DEFAULT_PEER_SERVICE_NAME
36
39
  )
37
40
  end
38
- o.lazy
39
41
  end
40
42
 
41
43
  option :error_status_codes do |o|
42
- o.default { env_to_list(Ext::ENV_ERROR_STATUS_CODES, 400...600, comma_separated_only: false) }
43
- o.lazy
44
+ o.env Ext::ENV_ERROR_STATUS_CODES
45
+ o.default 400...600
46
+ o.env_parser do |value|
47
+ values = if value.include?(',')
48
+ value.split(',')
49
+ else
50
+ value.split
51
+ end
52
+ values.map! do |v|
53
+ v.gsub!(/\A[\s,]*|[\s,]*\Z/, '')
54
+
55
+ v.empty? ? nil : v
56
+ end
57
+
58
+ values.compact!
59
+ values
60
+ end
61
+ end
62
+
63
+ option :peer_service do |o|
64
+ o.type :string, nilable: true
65
+ o.env Ext::ENV_PEER_SERVICE
44
66
  end
45
67
 
46
- option :split_by_domain, default: false
68
+ option :split_by_domain, default: false, type: :bool
47
69
  end
48
70
  end
49
71
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Tracing
3
5
  module Contrib
@@ -5,15 +7,20 @@ module Datadog
5
7
  # HTTP 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_HTTP_ENABLED'.freeze
9
- ENV_SERVICE_NAME = 'DD_TRACE_NET_HTTP_SERVICE_NAME'.freeze
10
- ENV_ANALYTICS_ENABLED = 'DD_TRACE_HTTP_ANALYTICS_ENABLED'.freeze
11
- ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_HTTP_ANALYTICS_SAMPLE_RATE'.freeze
12
- ENV_ERROR_STATUS_CODES = 'DD_TRACE_HTTP_ERROR_STATUS_CODES'.freeze
13
- DEFAULT_PEER_SERVICE_NAME = 'net/http'.freeze
14
- SPAN_REQUEST = 'http.request'.freeze
15
- TAG_COMPONENT = 'net/http'.freeze
16
- TAG_OPERATION_REQUEST = 'request'.freeze
10
+ ENV_ENABLED = 'DD_TRACE_HTTP_ENABLED'
11
+ ENV_SERVICE_NAME = 'DD_TRACE_NET_HTTP_SERVICE_NAME'
12
+ ENV_PEER_SERVICE = 'DD_TRACE_NET_HTTP_PEER_SERVICE'
13
+ ENV_ANALYTICS_ENABLED = 'DD_TRACE_HTTP_ANALYTICS_ENABLED'
14
+ ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_HTTP_ANALYTICS_SAMPLE_RATE'
15
+ ENV_ERROR_STATUS_CODES = 'DD_TRACE_HTTP_ERROR_STATUS_CODES'
16
+ DEFAULT_PEER_SERVICE_NAME = 'net/http'
17
+ SPAN_REQUEST = 'http.request'
18
+ TAG_COMPONENT = 'net/http'
19
+ TAG_OPERATION_REQUEST = 'request'
20
+ PEER_SERVICE_SOURCES = Array[
21
+ Tracing::Metadata::Ext::TAG_PEER_HOSTNAME,
22
+ Tracing::Metadata::Ext::NET::TAG_DESTINATION_NAME,
23
+ Tracing::Metadata::Ext::NET::TAG_TARGET_HOST,].freeze
17
24
  end
18
25
  end
19
26
  end
@@ -68,6 +68,13 @@ module Datadog
68
68
  end
69
69
 
70
70
  def annotate_span_with_request!(span, request, request_options)
71
+ if request_options[:peer_service]
72
+ span.set_tag(
73
+ Tracing::Metadata::Ext::TAG_PEER_SERVICE,
74
+ request_options[:peer_service]
75
+ )
76
+ end
77
+
71
78
  span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)
72
79
 
73
80
  span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
@@ -80,15 +87,16 @@ module Datadog
80
87
  span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_HOST, host)
81
88
  span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_PORT, port.to_s)
82
89
 
83
- if Contrib::SpanAttributeSchema.default_span_attribute_schema?
84
- # Tag as an external peer service
85
- span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service)
86
- end
87
-
88
90
  span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, host)
89
91
 
90
92
  # Set analytics sample rate
91
93
  set_analytics_sample_rate(span, request_options)
94
+
95
+ span.set_tags(
96
+ Datadog.configuration.tracing.header_tags.request_tags(request)
97
+ )
98
+
99
+ Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES)
92
100
  end
93
101
 
94
102
  def annotate_span_with_response!(span, response, request_options)
@@ -97,6 +105,10 @@ module Datadog
97
105
  span.set_tag(Tracing::Metadata::Ext::HTTP::TAG_STATUS_CODE, response.code)
98
106
 
99
107
  span.set_error(response) if request_options[:error_status_codes].include? response.code.to_i
108
+
109
+ span.set_tags(
110
+ Datadog.configuration.tracing.header_tags.response_tags(response)
111
+ )
100
112
  end
101
113
 
102
114
  def annotate_span_with_error!(span, error)
@@ -12,21 +12,24 @@ 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
- option :distributed_tracing, default: true
32
+ option :distributed_tracing, default: true, type: :bool
30
33
 
31
34
  option :service_name do |o|
32
35
  o.default do
@@ -35,15 +38,34 @@ module Datadog
35
38
  Ext::DEFAULT_PEER_SERVICE_NAME
36
39
  )
37
40
  end
38
- o.lazy
39
41
  end
40
42
 
41
43
  option :error_status_codes do |o|
42
- o.default { env_to_list(Ext::ENV_ERROR_STATUS_CODES, 400...600, comma_separated_only: false) }
43
- o.lazy
44
+ o.env Ext::ENV_ERROR_STATUS_CODES
45
+ o.default 400...600
46
+ o.env_parser do |value|
47
+ values = if value.include?(',')
48
+ value.split(',')
49
+ else
50
+ value.split
51
+ end
52
+ values.map! do |v|
53
+ v.gsub!(/\A[\s,]*|[\s,]*\Z/, '')
54
+
55
+ v.empty? ? nil : v
56
+ end
57
+
58
+ values.compact!
59
+ values
60
+ end
61
+ end
62
+
63
+ option :peer_service do |o|
64
+ o.type :string, nilable: true
65
+ o.env Ext::ENV_PEER_SERVICE
44
66
  end
45
67
 
46
- option :split_by_domain, default: false
68
+ option :split_by_domain, default: false, type: :bool
47
69
  end
48
70
  end
49
71
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Tracing
3
5
  module Contrib
@@ -5,15 +7,21 @@ module Datadog
5
7
  # Httpclient 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_HTTPCLIENT_ENABLED'.freeze
9
- ENV_SERVICE_NAME = 'DD_TRACE_HTTPCLIENT_SERVICE_NAME'.freeze
10
- ENV_ANALYTICS_ENABLED = 'DD_TRACE_HTTPCLIENT_ANALYTICS_ENABLED'.freeze
11
- ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_HTTPCLIENT_ANALYTICS_SAMPLE_RATE'.freeze
12
- ENV_ERROR_STATUS_CODES = 'DD_TRACE_HTTPCLIENT_ERROR_STATUS_CODES'.freeze
13
- DEFAULT_PEER_SERVICE_NAME = 'httpclient'.freeze
14
- SPAN_REQUEST = 'httpclient.request'.freeze
15
- TAG_COMPONENT = 'httpclient'.freeze
16
- TAG_OPERATION_REQUEST = 'request'.freeze
10
+ ENV_ENABLED = 'DD_TRACE_HTTPCLIENT_ENABLED'
11
+ ENV_SERVICE_NAME = 'DD_TRACE_HTTPCLIENT_SERVICE_NAME'
12
+ ENV_PEER_SERVICE = 'DD_TRACE_HTTPCLIENT_PEER_SERVICE'
13
+
14
+ ENV_ANALYTICS_ENABLED = 'DD_TRACE_HTTPCLIENT_ANALYTICS_ENABLED'
15
+ ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_HTTPCLIENT_ANALYTICS_SAMPLE_RATE'
16
+ ENV_ERROR_STATUS_CODES = 'DD_TRACE_HTTPCLIENT_ERROR_STATUS_CODES'
17
+ DEFAULT_PEER_SERVICE_NAME = 'httpclient'
18
+ SPAN_REQUEST = 'httpclient.request'
19
+ TAG_COMPONENT = 'httpclient'
20
+ TAG_OPERATION_REQUEST = 'request'
21
+ PEER_SERVICE_SOURCES = Array[
22
+ Tracing::Metadata::Ext::TAG_PEER_HOSTNAME,
23
+ Tracing::Metadata::Ext::NET::TAG_DESTINATION_NAME,
24
+ Tracing::Metadata::Ext::NET::TAG_TARGET_HOST,].freeze
17
25
  end
18
26
  end
19
27
  end
@@ -51,6 +51,13 @@ module Datadog
51
51
  def annotate_span_with_request!(span, req, req_options)
52
52
  span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)
53
53
 
54
+ if req_options[:peer_service]
55
+ span.set_tag(
56
+ Tracing::Metadata::Ext::TAG_PEER_SERVICE,
57
+ req_options[:peer_service]
58
+ )
59
+ end
60
+
54
61
  span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
55
62
  span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_REQUEST)
56
63
 
@@ -63,14 +70,15 @@ module Datadog
63
70
  span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_HOST, uri.host)
64
71
  span.set_tag(Tracing::Metadata::Ext::NET::TAG_TARGET_PORT, uri.port)
65
72
 
66
- if Contrib::SpanAttributeSchema.default_span_attribute_schema?
67
- # Tag as an external peer service
68
- span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service)
69
- end
70
-
71
73
  span.set_tag(Tracing::Metadata::Ext::TAG_PEER_HOSTNAME, uri.host)
72
74
 
73
75
  set_analytics_sample_rate(span, req_options)
76
+
77
+ span.set_tags(
78
+ Datadog.configuration.tracing.header_tags.request_tags(req.http_header)
79
+ )
80
+
81
+ Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES)
74
82
  end
75
83
 
76
84
  def annotate_span_with_response!(span, response, request_options)
@@ -81,6 +89,10 @@ module Datadog
81
89
  if request_options[:error_status_codes].include? response.code.to_i
82
90
  span.set_error(["Error #{response.status}", response.body])
83
91
  end
92
+
93
+ span.set_tags(
94
+ Datadog.configuration.tracing.header_tags.response_tags(response.header)
95
+ )
84
96
  end
85
97
 
86
98
  def annotate_span_with_error!(span, error)
@@ -12,21 +12,24 @@ 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
- option :distributed_tracing, default: true
32
+ option :distributed_tracing, default: true, type: :bool
30
33
 
31
34
  option :service_name do |o|
32
35
  o.default do
@@ -35,15 +38,34 @@ module Datadog
35
38
  Ext::DEFAULT_PEER_SERVICE_NAME
36
39
  )
37
40
  end
38
- o.lazy
39
41
  end
40
42
 
41
43
  option :error_status_codes do |o|
42
- o.default { env_to_list(Ext::ENV_ERROR_STATUS_CODES, 400...600, comma_separated_only: false) }
43
- o.lazy
44
+ o.env Ext::ENV_ERROR_STATUS_CODES
45
+ o.default 400...600
46
+ o.env_parser do |value|
47
+ values = if value.include?(',')
48
+ value.split(',')
49
+ else
50
+ value.split
51
+ end
52
+ values.map! do |v|
53
+ v.gsub!(/\A[\s,]*|[\s,]*\Z/, '')
54
+
55
+ v.empty? ? nil : v
56
+ end
57
+
58
+ values.compact!
59
+ values
60
+ end
61
+ end
62
+
63
+ option :peer_service do |o|
64
+ o.type :string, nilable: true
65
+ o.env Ext::ENV_PEER_SERVICE
44
66
  end
45
67
 
46
- option :split_by_domain, default: false
68
+ option :split_by_domain, default: false, type: :bool
47
69
  end
48
70
  end
49
71
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Datadog
2
4
  module Tracing
3
5
  module Contrib
@@ -5,15 +7,20 @@ module Datadog
5
7
  # Httprb 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_HTTPRB_ENABLED'.freeze
9
- ENV_SERVICE_NAME = 'DD_TRACE_HTTPRB_SERVICE_NAME'.freeze
10
- ENV_ANALYTICS_ENABLED = 'DD_TRACE_HTTPRB_ANALYTICS_ENABLED'.freeze
11
- ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_EHTTPRB_ANALYTICS_SAMPLE_RATE'.freeze
12
- ENV_ERROR_STATUS_CODES = 'DD_TRACE_HTTPCLIENT_ERROR_STATUS_CODES'.freeze
13
- DEFAULT_PEER_SERVICE_NAME = 'httprb'.freeze
14
- SPAN_REQUEST = 'httprb.request'.freeze
15
- TAG_COMPONENT = 'httprb'.freeze
16
- TAG_OPERATION_REQUEST = 'request'.freeze
10
+ ENV_ENABLED = 'DD_TRACE_HTTPRB_ENABLED'
11
+ ENV_SERVICE_NAME = 'DD_TRACE_HTTPRB_SERVICE_NAME'
12
+ ENV_PEER_SERVICE = 'DD_TRACE_HTTPRB_PEER_SERVICE'
13
+ ENV_ANALYTICS_ENABLED = 'DD_TRACE_HTTPRB_ANALYTICS_ENABLED'
14
+ ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_EHTTPRB_ANALYTICS_SAMPLE_RATE'
15
+ ENV_ERROR_STATUS_CODES = 'DD_TRACE_HTTPCLIENT_ERROR_STATUS_CODES'
16
+ DEFAULT_PEER_SERVICE_NAME = 'httprb'
17
+ SPAN_REQUEST = 'httprb.request'
18
+ TAG_COMPONENT = 'httprb'
19
+ TAG_OPERATION_REQUEST = 'request'
20
+ PEER_SERVICE_SOURCES = Array[
21
+ Tracing::Metadata::Ext::TAG_PEER_HOSTNAME,
22
+ Tracing::Metadata::Ext::NET::TAG_DESTINATION_NAME,
23
+ Tracing::Metadata::Ext::NET::TAG_TARGET_HOST,].freeze
17
24
  end
18
25
  end
19
26
  end
@@ -51,6 +51,13 @@ module Datadog
51
51
  def annotate_span_with_request!(span, req, req_options)
52
52
  span.set_tag(Tracing::Metadata::Ext::TAG_KIND, Tracing::Metadata::Ext::SpanKind::TAG_CLIENT)
53
53
 
54
+ if req_options[:peer_service]
55
+ span.set_tag(
56
+ Tracing::Metadata::Ext::TAG_PEER_SERVICE,
57
+ req_options[:peer_service]
58
+ )
59
+ end
60
+
54
61
  span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
55
62
  span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_REQUEST)
56
63
 
@@ -73,12 +80,13 @@ module Datadog
73
80
  logger.debug("service #{req_options[:service_name]} span #{Ext::SPAN_REQUEST} missing uri")
74
81
  end
75
82
 
76
- if Contrib::SpanAttributeSchema.default_span_attribute_schema?
77
- # Tag as an external peer service
78
- span.set_tag(Tracing::Metadata::Ext::TAG_PEER_SERVICE, span.service)
79
- end
80
-
81
83
  set_analytics_sample_rate(span, req_options)
84
+
85
+ span.set_tags(
86
+ Datadog.configuration.tracing.header_tags.request_tags(req.headers)
87
+ )
88
+
89
+ Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES)
82
90
  end
83
91
 
84
92
  def annotate_span_with_response!(span, response, request_options)
@@ -91,6 +99,10 @@ module Datadog
91
99
  # parsing the response body message will alter downstream application behavior
92
100
  span.set_error(["Error #{response.code}", 'Error'])
93
101
  end
102
+
103
+ span.set_tags(
104
+ Datadog.configuration.tracing.header_tags.response_tags(response.headers)
105
+ )
94
106
  end
95
107
 
96
108
  def annotate_span_with_error!(span, error)