ddtrace 1.5.2 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +56 -2
  3. data/ext/ddtrace_profiling_loader/ddtrace_profiling_loader.c +9 -2
  4. data/ext/ddtrace_profiling_loader/extconf.rb +17 -0
  5. data/ext/ddtrace_profiling_native_extension/NativeExtensionDesign.md +38 -2
  6. data/ext/ddtrace_profiling_native_extension/clock_id.h +1 -0
  7. data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +1 -0
  8. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.c +517 -42
  9. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time.h +3 -0
  10. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +208 -30
  11. data/ext/ddtrace_profiling_native_extension/collectors_stack.c +156 -46
  12. data/ext/ddtrace_profiling_native_extension/collectors_stack.h +11 -2
  13. data/ext/ddtrace_profiling_native_extension/extconf.rb +11 -1
  14. data/ext/ddtrace_profiling_native_extension/http_transport.c +83 -64
  15. data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.h +4 -4
  16. data/ext/ddtrace_profiling_native_extension/native_extension_helpers.rb +3 -2
  17. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +59 -0
  18. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +3 -0
  19. data/ext/ddtrace_profiling_native_extension/profiling.c +10 -0
  20. data/ext/ddtrace_profiling_native_extension/ruby_helpers.c +0 -1
  21. data/ext/ddtrace_profiling_native_extension/ruby_helpers.h +4 -2
  22. data/ext/ddtrace_profiling_native_extension/stack_recorder.c +45 -29
  23. data/ext/ddtrace_profiling_native_extension/stack_recorder.h +7 -7
  24. data/lib/datadog/appsec/contrib/rack/request_middleware.rb +4 -0
  25. data/lib/datadog/appsec/event.rb +6 -0
  26. data/lib/datadog/core/configuration/components.rb +20 -14
  27. data/lib/datadog/core/configuration/settings.rb +42 -4
  28. data/lib/datadog/core/diagnostics/environment_logger.rb +5 -1
  29. data/lib/datadog/core/utils/compression.rb +5 -1
  30. data/lib/datadog/core.rb +0 -54
  31. data/lib/datadog/profiling/collectors/cpu_and_wall_time.rb +12 -2
  32. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +5 -3
  33. data/lib/datadog/profiling/exporter.rb +2 -4
  34. data/lib/datadog/profiling/http_transport.rb +1 -1
  35. data/lib/datadog/tracing/configuration/ext.rb +1 -0
  36. data/lib/datadog/tracing/contrib/aws/instrumentation.rb +2 -0
  37. data/lib/datadog/tracing/contrib/dalli/ext.rb +1 -0
  38. data/lib/datadog/tracing/contrib/dalli/instrumentation.rb +4 -0
  39. data/lib/datadog/tracing/contrib/elasticsearch/ext.rb +2 -0
  40. data/lib/datadog/tracing/contrib/elasticsearch/patcher.rb +3 -0
  41. data/lib/datadog/tracing/contrib/ethon/easy_patch.rb +2 -0
  42. data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +2 -0
  43. data/lib/datadog/tracing/contrib/excon/middleware.rb +2 -0
  44. data/lib/datadog/tracing/contrib/ext.rb +6 -0
  45. data/lib/datadog/tracing/contrib/faraday/middleware.rb +2 -0
  46. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/client.rb +5 -0
  47. data/lib/datadog/tracing/contrib/grpc/datadog_interceptor/server.rb +7 -1
  48. data/lib/datadog/tracing/contrib/grpc/ext.rb +2 -0
  49. data/lib/datadog/tracing/contrib/hanami/action_tracer.rb +47 -0
  50. data/lib/datadog/tracing/contrib/hanami/configuration/settings.rb +22 -0
  51. data/lib/datadog/tracing/contrib/hanami/ext.rb +24 -0
  52. data/lib/datadog/tracing/contrib/hanami/integration.rb +44 -0
  53. data/lib/datadog/tracing/contrib/hanami/patcher.rb +33 -0
  54. data/lib/datadog/tracing/contrib/hanami/plugin.rb +23 -0
  55. data/lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb +41 -0
  56. data/lib/datadog/tracing/contrib/hanami/router_tracing.rb +44 -0
  57. data/lib/datadog/tracing/contrib/http/instrumentation.rb +2 -0
  58. data/lib/datadog/tracing/contrib/httpclient/instrumentation.rb +2 -0
  59. data/lib/datadog/tracing/contrib/httprb/instrumentation.rb +2 -0
  60. data/lib/datadog/tracing/contrib/mongodb/ext.rb +7 -0
  61. data/lib/datadog/tracing/contrib/mongodb/subscribers.rb +4 -0
  62. data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +12 -0
  63. data/lib/datadog/tracing/contrib/mysql2/ext.rb +1 -0
  64. data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +16 -0
  65. data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +12 -0
  66. data/lib/datadog/tracing/contrib/pg/ext.rb +2 -1
  67. data/lib/datadog/tracing/contrib/pg/instrumentation.rb +34 -18
  68. data/lib/datadog/tracing/contrib/propagation/sql_comment/comment.rb +43 -0
  69. data/lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb +32 -0
  70. data/lib/datadog/tracing/contrib/propagation/sql_comment/mode.rb +28 -0
  71. data/lib/datadog/tracing/contrib/propagation/sql_comment.rb +49 -0
  72. data/lib/datadog/tracing/contrib/rack/middlewares.rb +11 -5
  73. data/lib/datadog/tracing/contrib/redis/ext.rb +2 -0
  74. data/lib/datadog/tracing/contrib/redis/instrumentation.rb +4 -2
  75. data/lib/datadog/tracing/contrib/redis/integration.rb +2 -1
  76. data/lib/datadog/tracing/contrib/redis/patcher.rb +40 -0
  77. data/lib/datadog/tracing/contrib/redis/tags.rb +5 -0
  78. data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +2 -0
  79. data/lib/datadog/tracing/contrib/sinatra/env.rb +12 -23
  80. data/lib/datadog/tracing/contrib/sinatra/ext.rb +7 -3
  81. data/lib/datadog/tracing/contrib/sinatra/patcher.rb +2 -2
  82. data/lib/datadog/tracing/contrib/sinatra/tracer.rb +8 -80
  83. data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +14 -9
  84. data/lib/datadog/tracing/contrib.rb +1 -0
  85. data/lib/datadog/tracing/distributed/datadog_tags_codec.rb +84 -0
  86. data/lib/datadog/tracing/distributed/headers/datadog.rb +122 -30
  87. data/lib/datadog/tracing/distributed/headers/ext.rb +2 -0
  88. data/lib/datadog/tracing/flush.rb +1 -1
  89. data/lib/datadog/tracing/metadata/ext.rb +8 -0
  90. data/lib/datadog/tracing/propagation/http.rb +9 -1
  91. data/lib/datadog/tracing/sampling/ext.rb +31 -0
  92. data/lib/datadog/tracing/sampling/priority_sampler.rb +46 -4
  93. data/lib/datadog/tracing/sampling/rate_by_key_sampler.rb +8 -9
  94. data/lib/datadog/tracing/sampling/rate_by_service_sampler.rb +29 -5
  95. data/lib/datadog/tracing/sampling/rate_sampler.rb +10 -3
  96. data/lib/datadog/tracing/sampling/rule_sampler.rb +4 -3
  97. data/lib/datadog/tracing/sampling/span/ext.rb +0 -4
  98. data/lib/datadog/tracing/sampling/span/rule.rb +1 -1
  99. data/lib/datadog/tracing/sampling/span/sampler.rb +14 -3
  100. data/lib/datadog/tracing/trace_digest.rb +3 -0
  101. data/lib/datadog/tracing/trace_operation.rb +10 -0
  102. data/lib/datadog/tracing/trace_segment.rb +6 -0
  103. data/lib/datadog/tracing/tracer.rb +3 -1
  104. data/lib/datadog/tracing/writer.rb +7 -0
  105. data/lib/ddtrace/transport/trace_formatter.rb +7 -0
  106. data/lib/ddtrace/transport/traces.rb +1 -1
  107. data/lib/ddtrace/version.rb +2 -2
  108. metadata +18 -14
  109. data/lib/datadog/profiling/old_ext.rb +0 -42
  110. data/lib/datadog/profiling/transport/http/api/endpoint.rb +0 -85
  111. data/lib/datadog/profiling/transport/http/api/instance.rb +0 -38
  112. data/lib/datadog/profiling/transport/http/api/spec.rb +0 -42
  113. data/lib/datadog/profiling/transport/http/api.rb +0 -45
  114. data/lib/datadog/profiling/transport/http/builder.rb +0 -30
  115. data/lib/datadog/profiling/transport/http/client.rb +0 -37
  116. data/lib/datadog/profiling/transport/http/response.rb +0 -21
  117. data/lib/datadog/profiling/transport/http.rb +0 -118
@@ -12,7 +12,7 @@ module Datadog
12
12
  attr_reader \
13
13
  :default_key
14
14
 
15
- def initialize(default_key, default_rate = 1.0, &block)
15
+ def initialize(default_key, default_rate = 1.0, decision: nil, &block)
16
16
  super()
17
17
 
18
18
  raise ArgumentError, 'No resolver given!' unless block
@@ -22,7 +22,7 @@ module Datadog
22
22
  @mutex = Mutex.new
23
23
  @samplers = {}
24
24
 
25
- set_rate(default_key, default_rate)
25
+ set_rate(default_key, default_rate, decision)
26
26
  end
27
27
 
28
28
  def resolve(trace)
@@ -57,15 +57,15 @@ module Datadog
57
57
  end
58
58
  end
59
59
 
60
- def update(key, rate)
60
+ def update(key, rate, decision: nil)
61
61
  @mutex.synchronize do
62
- set_rate(key, rate)
62
+ set_rate(key, rate, decision)
63
63
  end
64
64
  end
65
65
 
66
- def update_all(rate_by_key)
66
+ def update_all(rate_by_key, decision: nil)
67
67
  @mutex.synchronize do
68
- rate_by_key.each { |key, rate| set_rate(key, rate) }
68
+ rate_by_key.each { |key, rate| set_rate(key, rate, decision) }
69
69
  end
70
70
  end
71
71
 
@@ -87,9 +87,8 @@ module Datadog
87
87
 
88
88
  private
89
89
 
90
- def set_rate(key, rate)
91
- @samplers[key] ||= RateSampler.new(rate)
92
- @samplers[key].sample_rate = rate
90
+ def set_rate(key, rate, decision)
91
+ @samplers[key] = RateSampler.new(rate, decision: decision)
93
92
  end
94
93
  end
95
94
  end
@@ -11,17 +11,23 @@ module Datadog
11
11
  class RateByServiceSampler < RateByKeySampler
12
12
  DEFAULT_KEY = 'service:,env:'.freeze
13
13
 
14
- def initialize(default_rate = 1.0, options = {})
15
- super(DEFAULT_KEY, default_rate, &method(:key_for))
16
- @env = options[:env]
14
+ def initialize(default_rate = 1.0, env: nil, decision: Datadog::Tracing::Sampling::Ext::Decision::DEFAULT)
15
+ super(
16
+ DEFAULT_KEY,
17
+ default_rate,
18
+ decision: decision,
19
+ &method(:key_for)
20
+ )
21
+
22
+ @env = env
17
23
  end
18
24
 
19
- def update(rate_by_service)
25
+ def update(rate_by_service, decision: nil)
20
26
  # Remove any old services
21
27
  delete_if { |key, _| key != DEFAULT_KEY && !rate_by_service.key?(key) }
22
28
 
23
29
  # Update each service rate
24
- update_all(rate_by_service)
30
+ update_all(rate_by_service, decision: decision)
25
31
 
26
32
  # Emit metric for service cache size
27
33
  Datadog.health_metrics.sampling_service_cache_length(length)
@@ -29,6 +35,24 @@ module Datadog
29
35
 
30
36
  private
31
37
 
38
+ # DEV: Creating a string on every trace to perform a single Hash lookup is expensive.
39
+ #
40
+ # Using 2 nested hashes: 1 for env and 1 for service is the fastest option.
41
+ # This approach requires large API changes to `RateByKeySampler`.
42
+ #
43
+ # Reducing the interpolated string size, by using a 1 character separator,
44
+ # is also measurably faster than the current method. This approach does not
45
+ # require changes to `RateByKeySampler`.
46
+ #
47
+ # Keep in mind that these changes also require changes to `#update`.
48
+ #
49
+ # Comparison:
50
+ # 2 nested hashes: `service_hash.fetch(service, {}).fetch(env, default_rate)`
51
+ # 7730045 i/s
52
+ # 1 char separator: `hash.fetch("#{service}\0#{env}", default_rate)`
53
+ # 4302801 i/s - 1.80x slower
54
+ # current: `hash.fetch("service:#{service},env:#{env}", default_rate)`
55
+ # 2720459 i/s - 2.84x slower
32
56
  def key_for(trace)
33
57
  # Resolve env dynamically, if Proc is given.
34
58
  env = @env.is_a?(Proc) ? @env.call : @env
@@ -30,7 +30,7 @@ module Datadog
30
30
  # DEV-2.0: sampler = RateSampler.new
31
31
  # DEV-2.0: sampler.sample_rate = sample_rate
32
32
  # DEV-2.0: ```
33
- def initialize(sample_rate = 1.0)
33
+ def initialize(sample_rate = 1.0, decision: nil)
34
34
  super()
35
35
 
36
36
  unless sample_rate > 0.0 && sample_rate <= 1.0
@@ -39,6 +39,8 @@ module Datadog
39
39
  end
40
40
 
41
41
  self.sample_rate = sample_rate
42
+
43
+ @decision = decision
42
44
  end
43
45
 
44
46
  def sample_rate(*_)
@@ -56,8 +58,13 @@ module Datadog
56
58
 
57
59
  def sample!(trace)
58
60
  sampled = trace.sampled = sample?(trace)
59
- trace.sample_rate = @sample_rate if sampled
60
- sampled
61
+
62
+ return false unless sampled
63
+
64
+ trace.sample_rate = @sample_rate
65
+ trace.set_tag(Tracing::Metadata::Ext::Distributed::TAG_DECISION_MAKER, @decision) if @decision
66
+
67
+ true
61
68
  end
62
69
  end
63
70
  end
@@ -48,7 +48,7 @@ module Datadog
48
48
  nil
49
49
  else
50
50
  # TODO: Simplify .tags access, as `Tracer#tags` can't be arbitrarily changed anymore
51
- RateByServiceSampler.new(1.0, env: -> { Tracing.send(:tracer).tags[:env] })
51
+ RateByServiceSampler.new(1.0, env: -> { Tracing.send(:tracer).tags['env'] })
52
52
  end
53
53
  end
54
54
 
@@ -76,10 +76,10 @@ module Datadog
76
76
  end
77
77
 
78
78
  # @!visibility private
79
- def update(*args)
79
+ def update(*args, **kwargs)
80
80
  return false unless @default_sampler.respond_to?(:update)
81
81
 
82
- @default_sampler.update(*args)
82
+ @default_sampler.update(*args, **kwargs)
83
83
  end
84
84
 
85
85
  private
@@ -100,6 +100,7 @@ module Datadog
100
100
  rate_limiter.allow?(1).tap do |allowed|
101
101
  set_priority(trace, allowed)
102
102
  set_limiter_metrics(trace, rate_limiter.effective_rate)
103
+ trace.set_tag(Tracing::Metadata::Ext::Distributed::TAG_DECISION_MAKER, Ext::Decision::TRACE_SAMPLING_RULE)
103
104
  end
104
105
  rescue StandardError => e
105
106
  Datadog.logger.error(
@@ -18,10 +18,6 @@ module Datadog
18
18
  TAG_RULE_RATE = '_dd.span_sampling.rule_rate'
19
19
  # Rate limit configured for this span, if a rule applies
20
20
  TAG_MAX_PER_SECOND = '_dd.span_sampling.max_per_second'
21
-
22
- # This span was sampled on account of a Span Sampling Rule
23
- # @see Datadog::Tracing::Sampling::Span::Rule
24
- MECHANISM_SPAN_SAMPLING_RATE = 8
25
21
  end
26
22
  end
27
23
  end
@@ -59,7 +59,7 @@ module Datadog
59
59
  return :not_matched unless @matcher.match?(span_op)
60
60
 
61
61
  if @sampler.sample?(span_op) && @rate_limiter.allow?(1)
62
- span_op.set_metric(Span::Ext::TAG_MECHANISM, Span::Ext::MECHANISM_SPAN_SAMPLING_RATE)
62
+ span_op.set_metric(Span::Ext::TAG_MECHANISM, Sampling::Ext::Mechanism::SPAN_SAMPLING_RATE)
63
63
  span_op.set_metric(Span::Ext::TAG_RULE_RATE, @sample_rate)
64
64
  span_op.set_metric(Span::Ext::TAG_MAX_PER_SECOND, @rate_limit)
65
65
  :kept
@@ -50,9 +50,20 @@ module Datadog
50
50
  def sample!(trace_op, span_op)
51
51
  return if trace_op.sampled? && trace_op.priority_sampled?
52
52
 
53
- # Return as soon as one rule matches
54
- @rules.any? do |rule|
55
- rule.sample!(span_op) != :not_matched
53
+ # Applies the first matching rule
54
+ @rules.each do |rule|
55
+ decision = rule.sample!(span_op)
56
+
57
+ next if decision == :not_matched # Iterate until we find a matching decision
58
+
59
+ if decision == :kept
60
+ trace_op.set_tag(
61
+ Metadata::Ext::Distributed::TAG_DECISION_MAKER,
62
+ Sampling::Ext::Decision::SPAN_SAMPLING_RATE
63
+ )
64
+ end
65
+
66
+ break # Found either a `kept` or `rejected` decision
56
67
  end
57
68
 
58
69
  nil
@@ -12,6 +12,7 @@ module Datadog
12
12
  :span_resource,
13
13
  :span_service,
14
14
  :span_type,
15
+ :trace_distributed_tags,
15
16
  :trace_hostname,
16
17
  :trace_id,
17
18
  :trace_name,
@@ -28,6 +29,7 @@ module Datadog
28
29
  span_resource: nil,
29
30
  span_service: nil,
30
31
  span_type: nil,
32
+ trace_distributed_tags: nil,
31
33
  trace_hostname: nil,
32
34
  trace_id: nil,
33
35
  trace_name: nil,
@@ -43,6 +45,7 @@ module Datadog
43
45
  @span_resource = span_resource && span_resource.dup.freeze
44
46
  @span_service = span_service && span_service.dup.freeze
45
47
  @span_type = span_type && span_type.dup.freeze
48
+ @trace_distributed_tags = trace_distributed_tags && trace_distributed_tags.dup.freeze
46
49
  @trace_hostname = trace_hostname && trace_hostname.dup.freeze
47
50
  @trace_id = trace_id
48
51
  @trace_name = trace_name && trace_name.dup.freeze
@@ -133,11 +133,13 @@ module Datadog
133
133
  def keep!
134
134
  self.sampled = true
135
135
  self.sampling_priority = Sampling::Ext::Priority::USER_KEEP
136
+ set_tag(Tracing::Metadata::Ext::Distributed::TAG_DECISION_MAKER, Tracing::Sampling::Ext::Decision::MANUAL)
136
137
  end
137
138
 
138
139
  def reject!
139
140
  self.sampled = false
140
141
  self.sampling_priority = Sampling::Ext::Priority::USER_REJECT
142
+ set_tag(Tracing::Metadata::Ext::Distributed::TAG_DECISION_MAKER, Tracing::Sampling::Ext::Decision::MANUAL)
141
143
  end
142
144
 
143
145
  def name
@@ -278,6 +280,7 @@ module Datadog
278
280
  span_resource: (@active_span && @active_span.resource),
279
281
  span_service: (@active_span && @active_span.service),
280
282
  span_type: (@active_span && @active_span.type),
283
+ trace_distributed_tags: distributed_tags,
281
284
  trace_hostname: @hostname,
282
285
  trace_id: @id,
283
286
  trace_name: name,
@@ -452,6 +455,13 @@ module Datadog
452
455
  root_span_id: !partial ? root_span && root_span.id : nil
453
456
  )
454
457
  end
458
+
459
+ # Returns tracer tags that will be propagated if this span's context
460
+ # is exported through {.to_digest}.
461
+ # @return [Hash] key value pairs of distributed tags
462
+ def distributed_tags
463
+ meta.select { |name, _| name.start_with?(Metadata::Ext::Distributed::TAGS_PREFIX) }
464
+ end
455
465
  end
456
466
  end
457
467
  end
@@ -30,6 +30,7 @@ module Datadog
30
30
  :rule_sample_rate,
31
31
  :runtime_id,
32
32
  :sample_rate,
33
+ :sampling_decision_maker,
33
34
  :sampling_priority,
34
35
  :service
35
36
 
@@ -77,6 +78,7 @@ module Datadog
77
78
  @rule_sample_rate = rule_sample_rate_tag || rule_sample_rate
78
79
  @runtime_id = runtime_id || runtime_id_tag
79
80
  @sample_rate = sample_rate || sample_rate_tag
81
+ @sampling_decision_maker = sampling_decision_maker_tag
80
82
  @sampling_priority = sampling_priority || sampling_priority_tag
81
83
  @service = Core::Utils::SafeDup.frozen_or_dup(service || service_tag)
82
84
  end
@@ -194,6 +196,10 @@ module Datadog
194
196
  metrics[Metadata::Ext::Sampling::TAG_SAMPLE_RATE]
195
197
  end
196
198
 
199
+ def sampling_decision_maker_tag
200
+ meta[Metadata::Ext::Distributed::TAG_DECISION_MAKER]
201
+ end
202
+
197
203
  def sampling_priority_tag
198
204
  meta[Metadata::Ext::Distributed::TAG_SAMPLING_PRIORITY]
199
205
  end
@@ -326,7 +326,9 @@ module Datadog
326
326
  id: digest.trace_id,
327
327
  origin: digest.trace_origin,
328
328
  parent_span_id: digest.span_id,
329
- sampling_priority: digest.trace_sampling_priority
329
+ sampling_priority: digest.trace_sampling_priority,
330
+ # Distributed tags are just regular trace tags with special meaning to Datadog
331
+ tags: digest.trace_distributed_tags,
330
332
  )
331
333
  else
332
334
  TraceOperation.new(
@@ -175,6 +175,13 @@ module Datadog
175
175
  end
176
176
  end
177
177
  end
178
+
179
+ private
180
+
181
+ def reset_stats!
182
+ @traces_flushed = 0
183
+ @transport.stats.reset!
184
+ end
178
185
  end
179
186
  end
180
187
  end
@@ -48,6 +48,7 @@ module Datadog
48
48
  tag_runtime_id!
49
49
  tag_rate_limiter_rate!
50
50
  tag_sample_rate!
51
+ tag_sampling_decision_maker!
51
52
  tag_sampling_priority!
52
53
 
53
54
  trace
@@ -155,6 +156,12 @@ module Datadog
155
156
  )
156
157
  end
157
158
 
159
+ def tag_sampling_decision_maker!
160
+ return unless (decision = trace.sampling_decision_maker)
161
+
162
+ root_span.set_tag(Tracing::Metadata::Ext::Distributed::TAG_DECISION_MAKER, decision)
163
+ end
164
+
158
165
  def tag_sampling_priority!
159
166
  return unless trace.sampling_priority
160
167
 
@@ -80,7 +80,7 @@ module Datadog
80
80
 
81
81
  if encoded.size > max_size
82
82
  # This single trace is too large, we can't flush it
83
- Datadog.logger.debug { "Dropping trace. Payload too large: '#{trace.map(&:to_hash)}'" }
83
+ Datadog.logger.debug { "Dropping trace. Payload too large: '#{trace.inspect}'" }
84
84
  Datadog.health_metrics.transport_trace_too_large(1)
85
85
 
86
86
  return nil
@@ -3,8 +3,8 @@
3
3
  module DDTrace
4
4
  module VERSION
5
5
  MAJOR = 1
6
- MINOR = 5
7
- PATCH = 2
6
+ MINOR = 6
7
+ PATCH = 1
8
8
  PRE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddtrace
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 1980-01-01 00:00:00.000000000 Z
11
+ date: 2022-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: 0.7.0.1.1
67
+ version: 0.9.0.1.0
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: 0.7.0.1.1
74
+ version: 0.9.0.1.0
75
75
  description: |
76
76
  ddtrace is Datadog's tracing client for Ruby. It is used to trace requests
77
77
  as they flow across web servers, databases and microservices so that developers
@@ -314,7 +314,6 @@ files:
314
314
  - lib/datadog/profiling/http_transport.rb
315
315
  - lib/datadog/profiling/load_native_extension.rb
316
316
  - lib/datadog/profiling/native_extension.rb
317
- - lib/datadog/profiling/old_ext.rb
318
317
  - lib/datadog/profiling/old_recorder.rb
319
318
  - lib/datadog/profiling/pprof/builder.rb
320
319
  - lib/datadog/profiling/pprof/converter.rb
@@ -335,14 +334,6 @@ files:
335
334
  - lib/datadog/profiling/tasks/setup.rb
336
335
  - lib/datadog/profiling/trace_identifiers/ddtrace.rb
337
336
  - lib/datadog/profiling/trace_identifiers/helper.rb
338
- - lib/datadog/profiling/transport/http.rb
339
- - lib/datadog/profiling/transport/http/api.rb
340
- - lib/datadog/profiling/transport/http/api/endpoint.rb
341
- - lib/datadog/profiling/transport/http/api/instance.rb
342
- - lib/datadog/profiling/transport/http/api/spec.rb
343
- - lib/datadog/profiling/transport/http/builder.rb
344
- - lib/datadog/profiling/transport/http/client.rb
345
- - lib/datadog/profiling/transport/http/response.rb
346
337
  - lib/datadog/tracing.rb
347
338
  - lib/datadog/tracing/analytics.rb
348
339
  - lib/datadog/tracing/buffer.rb
@@ -505,6 +496,14 @@ files:
505
496
  - lib/datadog/tracing/contrib/grpc/integration.rb
506
497
  - lib/datadog/tracing/contrib/grpc/intercept_with_datadog.rb
507
498
  - lib/datadog/tracing/contrib/grpc/patcher.rb
499
+ - lib/datadog/tracing/contrib/hanami/action_tracer.rb
500
+ - lib/datadog/tracing/contrib/hanami/configuration/settings.rb
501
+ - lib/datadog/tracing/contrib/hanami/ext.rb
502
+ - lib/datadog/tracing/contrib/hanami/integration.rb
503
+ - lib/datadog/tracing/contrib/hanami/patcher.rb
504
+ - lib/datadog/tracing/contrib/hanami/plugin.rb
505
+ - lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb
506
+ - lib/datadog/tracing/contrib/hanami/router_tracing.rb
508
507
  - lib/datadog/tracing/contrib/http/circuit_breaker.rb
509
508
  - lib/datadog/tracing/contrib/http/configuration/settings.rb
510
509
  - lib/datadog/tracing/contrib/http/ext.rb
@@ -569,6 +568,10 @@ files:
569
568
  - lib/datadog/tracing/contrib/presto/instrumentation.rb
570
569
  - lib/datadog/tracing/contrib/presto/integration.rb
571
570
  - lib/datadog/tracing/contrib/presto/patcher.rb
571
+ - lib/datadog/tracing/contrib/propagation/sql_comment.rb
572
+ - lib/datadog/tracing/contrib/propagation/sql_comment/comment.rb
573
+ - lib/datadog/tracing/contrib/propagation/sql_comment/ext.rb
574
+ - lib/datadog/tracing/contrib/propagation/sql_comment/mode.rb
572
575
  - lib/datadog/tracing/contrib/qless/configuration/settings.rb
573
576
  - lib/datadog/tracing/contrib/qless/ext.rb
574
577
  - lib/datadog/tracing/contrib/qless/integration.rb
@@ -686,6 +689,7 @@ files:
686
689
  - lib/datadog/tracing/contrib/utils/quantization/hash.rb
687
690
  - lib/datadog/tracing/contrib/utils/quantization/http.rb
688
691
  - lib/datadog/tracing/correlation.rb
692
+ - lib/datadog/tracing/distributed/datadog_tags_codec.rb
689
693
  - lib/datadog/tracing/distributed/headers/b3.rb
690
694
  - lib/datadog/tracing/distributed/headers/b3_single.rb
691
695
  - lib/datadog/tracing/distributed/headers/datadog.rb
@@ -792,7 +796,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
792
796
  - !ruby/object:Gem::Version
793
797
  version: 2.0.0
794
798
  requirements: []
795
- rubygems_version: 3.2.26
799
+ rubygems_version: 3.3.7
796
800
  signing_key:
797
801
  specification_version: 4
798
802
  summary: Datadog tracing code for your Ruby applications
@@ -1,42 +0,0 @@
1
- # typed: true
2
-
3
- module Datadog
4
- module Profiling
5
- # NOTE: This OldExt file is temporary and expected to be removed once the migration to the new `HttpTransport` class
6
- # is complete
7
- module OldExt
8
- module Transport
9
- module HTTP
10
- URI_TEMPLATE_DD_API = 'https://intake.profile.%s/'.freeze
11
-
12
- FORM_FIELD_RECORDING_START = 'start'.freeze
13
- FORM_FIELD_RECORDING_END = 'end'.freeze
14
- FORM_FIELD_FAMILY = 'family'.freeze
15
- FORM_FIELD_TAG_ENV = 'env'.freeze
16
- FORM_FIELD_TAG_HOST = 'host'.freeze
17
- FORM_FIELD_TAG_LANGUAGE = 'language'.freeze
18
- FORM_FIELD_TAG_PID = 'process_id'.freeze
19
- FORM_FIELD_TAG_PROFILER_VERSION = 'profiler_version'.freeze
20
- FORM_FIELD_TAG_RUNTIME = 'runtime'.freeze
21
- FORM_FIELD_TAG_RUNTIME_ENGINE = 'runtime_engine'.freeze
22
- FORM_FIELD_TAG_RUNTIME_ID = 'runtime-id'.freeze
23
- FORM_FIELD_TAG_RUNTIME_PLATFORM = 'runtime_platform'.freeze
24
- FORM_FIELD_TAG_RUNTIME_VERSION = 'runtime_version'.freeze
25
- FORM_FIELD_TAG_SERVICE = 'service'.freeze
26
- FORM_FIELD_TAG_VERSION = 'version'.freeze
27
- FORM_FIELD_TAGS = 'tags'.freeze
28
- FORM_FIELD_INTAKE_VERSION = 'version'.freeze
29
-
30
- HEADER_CONTENT_TYPE = 'Content-Type'.freeze
31
- HEADER_CONTENT_TYPE_OCTET_STREAM = 'application/octet-stream'.freeze
32
-
33
- FORM_FIELD_PPROF_DATA = 'data[rubyprofile.pprof]'.freeze
34
- PPROF_DEFAULT_FILENAME = 'rubyprofile.pprof.gz'.freeze
35
-
36
- FORM_FIELD_CODE_PROVENANCE_DATA = 'data[code-provenance.json]'.freeze
37
- CODE_PROVENANCE_FILENAME = 'code-provenance.json.gz'.freeze
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,85 +0,0 @@
1
- # typed: true
2
-
3
- require_relative '../../../../core/utils/compression'
4
- require_relative '../../../../core/vendor/multipart-post/multipart/post/composite_read_io'
5
- require_relative '../../../old_ext'
6
- require_relative '../response'
7
- require_relative '../../../../../ddtrace/transport/http/api/endpoint'
8
-
9
- module Datadog
10
- module Profiling
11
- module Transport
12
- module HTTP
13
- module API
14
- # Datadog API endpoint for profiling
15
- class Endpoint < Datadog::Transport::HTTP::API::Endpoint
16
- include Profiling::OldExt::Transport::HTTP
17
-
18
- # These tags are read from the flush object (see below) directly and so we ignore any extra copies that
19
- # may come in the tags hash to avoid duplicates.
20
- TAGS_TO_IGNORE_IN_TAGS_HASH = %w[service env version].freeze
21
- private_constant :TAGS_TO_IGNORE_IN_TAGS_HASH
22
-
23
- attr_reader \
24
- :encoder
25
-
26
- def initialize(path, encoder = nil)
27
- super(:post, path)
28
- @encoder = encoder
29
- end
30
-
31
- def call(env, &block)
32
- # Build request
33
- env.form = build_form(env)
34
-
35
- # Send request
36
- http_response = super(env, &block)
37
-
38
- # Build response
39
- Profiling::Transport::HTTP::Response.new(http_response)
40
- end
41
-
42
- def build_form(env)
43
- flush = env.request
44
- pprof_file = build_pprof(flush)
45
-
46
- form = {
47
- FORM_FIELD_INTAKE_VERSION => '3', # Aka 1.3 intake format
48
- FORM_FIELD_RECORDING_START => flush.start.utc.iso8601,
49
- FORM_FIELD_RECORDING_END => flush.finish.utc.iso8601,
50
- FORM_FIELD_TAGS => flush.tags_as_array.map { |key, value| "#{key}:#{value}" },
51
- FORM_FIELD_PPROF_DATA => pprof_file,
52
- FORM_FIELD_FAMILY => 'ruby',
53
- }
54
-
55
- # May not be available/enabled
56
- form[FORM_FIELD_CODE_PROVENANCE_DATA] = build_code_provenance(flush) if flush.code_provenance_data
57
-
58
- form
59
- end
60
-
61
- def build_pprof(flush)
62
- gzipped_pprof_data = flush.pprof_data
63
-
64
- Core::Vendor::Multipart::Post::UploadIO.new(
65
- StringIO.new(gzipped_pprof_data),
66
- HEADER_CONTENT_TYPE_OCTET_STREAM,
67
- PPROF_DEFAULT_FILENAME
68
- )
69
- end
70
-
71
- def build_code_provenance(flush)
72
- gzipped_code_provenance = flush.code_provenance_data
73
-
74
- Core::Vendor::Multipart::Post::UploadIO.new(
75
- StringIO.new(gzipped_code_provenance),
76
- HEADER_CONTENT_TYPE_OCTET_STREAM,
77
- CODE_PROVENANCE_FILENAME,
78
- )
79
- end
80
- end
81
- end
82
- end
83
- end
84
- end
85
- end
@@ -1,38 +0,0 @@
1
- # typed: true
2
-
3
- require_relative '../../../../../ddtrace/transport/http/api/instance'
4
- require_relative 'spec'
5
-
6
- module Datadog
7
- module Profiling
8
- module Transport
9
- module HTTP
10
- module API
11
- # API instance for profiling
12
- class Instance < Datadog::Transport::HTTP::API::Instance
13
- def send_profiling_flush(env)
14
- raise ProfilesNotSupportedError, spec unless spec.is_a?(Spec)
15
-
16
- spec.send_profiling_flush(env) do |request_env|
17
- call(request_env)
18
- end
19
- end
20
-
21
- # Raised when profiles sent to API that does not support profiles
22
- class ProfilesNotSupportedError < StandardError
23
- attr_reader :spec
24
-
25
- def initialize(spec)
26
- @spec = spec
27
- end
28
-
29
- def message
30
- 'Profiles not supported for this API!'
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
38
- end