ddtrace 0.43.0 → 0.44.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +100 -129
  3. data/.circleci/images/primary/Dockerfile-3.0.0 +73 -0
  4. data/.github/workflows/add-milestone-to-pull-requests.yml +1 -1
  5. data/.simplecov +4 -1
  6. data/Appraisals +200 -8
  7. data/CHANGELOG.md +1005 -376
  8. data/Gemfile +4 -2
  9. data/Rakefile +121 -4
  10. data/ddtrace.gemspec +5 -8
  11. data/docker-compose.yml +30 -0
  12. data/docs/GettingStarted.md +47 -8
  13. data/lib/ddtrace.rb +1 -0
  14. data/lib/ddtrace/contrib/action_view/event.rb +0 -4
  15. data/lib/ddtrace/contrib/action_view/events/render_partial.rb +1 -0
  16. data/lib/ddtrace/contrib/action_view/events/render_template.rb +1 -0
  17. data/lib/ddtrace/contrib/active_record/utils.rb +11 -1
  18. data/lib/ddtrace/contrib/aws/services.rb +1 -0
  19. data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +2 -0
  20. data/lib/ddtrace/contrib/ethon/easy_patch.rb +1 -1
  21. data/lib/ddtrace/contrib/ethon/ext.rb +1 -0
  22. data/lib/ddtrace/contrib/grape/endpoint.rb +29 -11
  23. data/lib/ddtrace/contrib/grape/ext.rb +1 -0
  24. data/lib/ddtrace/contrib/httprb/instrumentation.rb +1 -1
  25. data/lib/ddtrace/contrib/qless/configuration/settings.rb +35 -0
  26. data/lib/ddtrace/contrib/qless/ext.rb +20 -0
  27. data/lib/ddtrace/contrib/qless/integration.rb +38 -0
  28. data/lib/ddtrace/contrib/qless/patcher.rb +35 -0
  29. data/lib/ddtrace/contrib/qless/qless_job.rb +72 -0
  30. data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +32 -0
  31. data/lib/ddtrace/contrib/redis/configuration/resolver.rb +3 -1
  32. data/lib/ddtrace/contrib/redis/configuration/settings.rb +5 -0
  33. data/lib/ddtrace/contrib/redis/ext.rb +1 -0
  34. data/lib/ddtrace/contrib/redis/patcher.rb +20 -3
  35. data/lib/ddtrace/contrib/redis/quantize.rb +27 -0
  36. data/lib/ddtrace/contrib/redis/tags.rb +5 -1
  37. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +2 -2
  38. data/lib/ddtrace/ext/ci.rb +0 -1
  39. data/lib/ddtrace/version.rb +1 -1
  40. data/lib/ddtrace/workers/runtime_metrics.rb +7 -3
  41. metadata +77 -29
@@ -9,6 +9,7 @@ module Datadog
9
9
  ENV_ANALYTICS_ENABLED_OLD = 'DD_REDIS_ANALYTICS_ENABLED'.freeze
10
10
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_REDIS_ANALYTICS_SAMPLE_RATE'.freeze
11
11
  ENV_ANALYTICS_SAMPLE_RATE_OLD = 'DD_REDIS_ANALYTICS_SAMPLE_RATE'.freeze
12
+ ENV_COMMAND_ARGS = 'DD_REDIS_COMMAND_ARGS'.freeze
12
13
  METRIC_PIPELINE_LEN = 'redis.pipeline_length'.freeze
13
14
  SERVICE_NAME = 'redis'.freeze
14
15
  SPAN_COMMAND = 'redis.command'.freeze
@@ -28,6 +28,7 @@ module Datadog
28
28
 
29
29
  # rubocop:disable Metrics/MethodLength
30
30
  # rubocop:disable Metrics/BlockLength
31
+ # rubocop:disable Metrics/AbcSize
31
32
  def patch_redis_client
32
33
  ::Redis::Client.class_eval do
33
34
  alias_method :call_without_datadog, :call
@@ -40,7 +41,7 @@ module Datadog
40
41
  pin.tracer.trace(Datadog::Contrib::Redis::Ext::SPAN_COMMAND) do |span|
41
42
  span.service = pin.service
42
43
  span.span_type = Datadog::Contrib::Redis::Ext::TYPE
43
- span.resource = Datadog::Contrib::Redis::Quantize.format_command_args(*args)
44
+ span.resource = get_command(args)
44
45
  Datadog::Contrib::Redis::Tags.set_common_tags(self, span)
45
46
 
46
47
  response = call_without_datadog(*args, &block)
@@ -59,10 +60,10 @@ module Datadog
59
60
  pin.tracer.trace(Datadog::Contrib::Redis::Ext::SPAN_COMMAND) do |span|
60
61
  span.service = pin.service
61
62
  span.span_type = Datadog::Contrib::Redis::Ext::TYPE
62
- commands = args[0].commands.map { |c| Datadog::Contrib::Redis::Quantize.format_command_args(c) }
63
+ commands = get_pipeline_commands(args)
63
64
  span.resource = commands.join("\n")
64
- Datadog::Contrib::Redis::Tags.set_common_tags(self, span)
65
65
  span.set_metric Datadog::Contrib::Redis::Ext::METRIC_PIPELINE_LEN, commands.length
66
+ Datadog::Contrib::Redis::Tags.set_common_tags(self, span)
66
67
 
67
68
  response = call_pipeline_without_datadog(*args, &block)
68
69
  end
@@ -84,6 +85,22 @@ module Datadog
84
85
 
85
86
  private
86
87
 
88
+ def get_command(args)
89
+ if datadog_configuration[:command_args]
90
+ Datadog::Contrib::Redis::Quantize.format_command_args(*args)
91
+ else
92
+ Datadog::Contrib::Redis::Quantize.get_verb(*args)
93
+ end
94
+ end
95
+
96
+ def get_pipeline_commands(args)
97
+ if datadog_configuration[:command_args]
98
+ args[0].commands.map { |c| Datadog::Contrib::Redis::Quantize.format_command_args(c) }
99
+ else
100
+ args[0].commands.map { |c| Datadog::Contrib::Redis::Quantize.get_verb(c) }
101
+ end
102
+ end
103
+
87
104
  def datadog_configuration
88
105
  Datadog.configuration[:redis, options]
89
106
  end
@@ -1,3 +1,5 @@
1
+ require 'set'
2
+
1
3
  module Datadog
2
4
  module Contrib
3
5
  module Redis
@@ -8,6 +10,19 @@ module Datadog
8
10
  VALUE_MAX_LEN = 50
9
11
  CMD_MAX_LEN = 500
10
12
 
13
+ MULTI_VERB_COMMANDS = Set.new(
14
+ %w[
15
+ ACL
16
+ CLIENT
17
+ CLUSTER
18
+ COMMAND
19
+ CONFIG
20
+ DEBUG
21
+ LATENCY
22
+ MEMORY
23
+ ]
24
+ ).freeze
25
+
11
26
  module_function
12
27
 
13
28
  def format_arg(arg)
@@ -27,6 +42,18 @@ module Datadog
27
42
  Utils.truncate(cmd, CMD_MAX_LEN, TOO_LONG_MARK)
28
43
  end
29
44
 
45
+ def get_verb(command_args)
46
+ return unless command_args.is_a?(Array)
47
+
48
+ return get_verb(command_args.first) if command_args.first.is_a?(Array)
49
+
50
+ arg = command_args.first
51
+ verb = arg.is_a?(Symbol) ? arg.to_s.upcase : arg.to_s
52
+ return verb unless MULTI_VERB_COMMANDS.include?(verb) && command_args[1]
53
+
54
+ "#{verb} #{command_args[1]}"
55
+ end
56
+
30
57
  def auth_command?(command_args)
31
58
  return false unless command_args.is_a?(Array) && !command_args.empty?
32
59
  command_args.first.to_sym == :auth
@@ -19,7 +19,7 @@ module Datadog
19
19
  span.set_tag Datadog::Ext::NET::TARGET_HOST, client.host
20
20
  span.set_tag Datadog::Ext::NET::TARGET_PORT, client.port
21
21
  span.set_tag Ext::TAG_DB, client.db
22
- span.set_tag Ext::TAG_RAW_COMMAND, span.resource
22
+ span.set_tag Ext::TAG_RAW_COMMAND, span.resource if show_command_args?
23
23
  end
24
24
 
25
25
  private
@@ -35,6 +35,10 @@ module Datadog
35
35
  def analytics_sample_rate
36
36
  datadog_configuration[:analytics_sample_rate]
37
37
  end
38
+
39
+ def show_command_args?
40
+ datadog_configuration[:command_args]
41
+ end
38
42
  end
39
43
  end
40
44
  end
@@ -8,9 +8,9 @@ module Datadog
8
8
  module Sinatra
9
9
  # Middleware used for automatically tagging configured headers and handle request span
10
10
  class TracerMiddleware
11
- def initialize(app, app_instance: nil)
11
+ def initialize(app, opt = {})
12
12
  @app = app
13
- @app_instance = app_instance
13
+ @app_instance = opt[:app_instance]
14
14
  end
15
15
 
16
16
  # rubocop:disable Metrics/AbcSize
@@ -221,7 +221,6 @@ module Datadog
221
221
  Git::TAG_COMMIT_SHA => env['GIT_COMMIT'],
222
222
  Git::TAG_REPOSITORY_URL => env['GIT_URL'],
223
223
  Git::TAG_TAG => tag,
224
- TAG_JOB_URL => env['JOB_URL'],
225
224
  TAG_PIPELINE_ID => env['BUILD_TAG'],
226
225
  TAG_PIPELINE_NAME => name,
227
226
  TAG_PIPELINE_NUMBER => env['BUILD_NUMBER'],
@@ -1,7 +1,7 @@
1
1
  module Datadog
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 43
4
+ MINOR = 44
5
5
  PATCH = 0
6
6
  PRE = nil
7
7
 
@@ -12,6 +12,10 @@ module Datadog
12
12
  extend Forwardable
13
13
  include Workers::Polling
14
14
 
15
+ # In seconds
16
+ DEFAULT_FLUSH_INTERVAL = 10
17
+ DEFAULT_BACK_OFF_MAX = 30
18
+
15
19
  attr_reader \
16
20
  :metrics
17
21
 
@@ -22,9 +26,9 @@ module Datadog
22
26
  self.fork_policy = options.fetch(:fork_policy, Workers::Async::Thread::FORK_POLICY_STOP)
23
27
 
24
28
  # Workers::IntervalLoop settings
25
- self.interval = options[:interval] if options.key?(:interval)
26
- self.back_off_ratio = options[:back_off_ratio] if options.key?(:back_off_ratio)
27
- self.back_off_max = options[:back_off_max] if options.key?(:back_off_max)
29
+ self.loop_base_interval = options.fetch(:interval, DEFAULT_FLUSH_INTERVAL)
30
+ self.loop_back_off_ratio = options[:back_off_ratio] if options.key?(:back_off_ratio)
31
+ self.loop_back_off_max = options.fetch(:back_off_max, DEFAULT_BACK_OFF_MAX)
28
32
 
29
33
  self.enabled = options.fetch(:enabled, false)
30
34
  end
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: 0.43.0
4
+ version: 0.44.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-18 00:00:00.000000000 Z
11
+ date: 2021-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.1'
125
+ - !ruby/object:Gem::Dependency
126
+ name: ruby-prof
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.4'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.4'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: minitest
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +178,20 @@ dependencies:
164
178
  - - '='
165
179
  - !ruby/object:Gem::Version
166
180
  version: 1.0.2
181
+ - !ruby/object:Gem::Dependency
182
+ name: pimpmychangelog
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: 0.1.2
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: 0.1.2
167
195
  - !ruby/object:Gem::Dependency
168
196
  name: appraisal
169
197
  requirement: !ruby/object:Gem::Requirement
@@ -196,16 +224,16 @@ dependencies:
196
224
  name: webmock
197
225
  requirement: !ruby/object:Gem::Requirement
198
226
  requirements:
199
- - - "~>"
227
+ - - ">="
200
228
  - !ruby/object:Gem::Version
201
- version: '2.0'
229
+ version: 3.10.0
202
230
  type: :development
203
231
  prerelease: false
204
232
  version_requirements: !ruby/object:Gem::Requirement
205
233
  requirements:
206
- - - "~>"
234
+ - - ">="
207
235
  - !ruby/object:Gem::Version
208
- version: '2.0'
236
+ version: 3.10.0
209
237
  - !ruby/object:Gem::Dependency
210
238
  name: builder
211
239
  requirement: !ruby/object:Gem::Requirement
@@ -220,20 +248,6 @@ dependencies:
220
248
  - - ">="
221
249
  - !ruby/object:Gem::Version
222
250
  version: '0'
223
- - !ruby/object:Gem::Dependency
224
- name: sqlite3
225
- requirement: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - "~>"
228
- - !ruby/object:Gem::Version
229
- version: 1.3.6
230
- type: :development
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - "~>"
235
- - !ruby/object:Gem::Version
236
- version: 1.3.6
237
251
  - !ruby/object:Gem::Dependency
238
252
  name: climate_control
239
253
  requirement: !ruby/object:Gem::Requirement
@@ -324,28 +338,42 @@ dependencies:
324
338
  requirements:
325
339
  - - "~>"
326
340
  - !ruby/object:Gem::Version
327
- version: 0.10.4
341
+ version: 0.12.2
328
342
  type: :development
329
343
  prerelease: false
330
344
  version_requirements: !ruby/object:Gem::Requirement
331
345
  requirements:
332
346
  - - "~>"
333
347
  - !ruby/object:Gem::Version
334
- version: 0.10.4
348
+ version: 0.12.2
349
+ - !ruby/object:Gem::Dependency
350
+ name: pry-nav
351
+ requirement: !ruby/object:Gem::Requirement
352
+ requirements:
353
+ - - "~>"
354
+ - !ruby/object:Gem::Version
355
+ version: 0.3.0
356
+ type: :development
357
+ prerelease: false
358
+ version_requirements: !ruby/object:Gem::Requirement
359
+ requirements:
360
+ - - "~>"
361
+ - !ruby/object:Gem::Version
362
+ version: 0.3.0
335
363
  - !ruby/object:Gem::Dependency
336
364
  name: pry-stack_explorer
337
365
  requirement: !ruby/object:Gem::Requirement
338
366
  requirements:
339
367
  - - "~>"
340
368
  - !ruby/object:Gem::Version
341
- version: 0.4.9.2
369
+ version: 0.4.9
342
370
  type: :development
343
371
  prerelease: false
344
372
  version_requirements: !ruby/object:Gem::Requirement
345
373
  requirements:
346
374
  - - "~>"
347
375
  - !ruby/object:Gem::Version
348
- version: 0.4.9.2
376
+ version: 0.4.9
349
377
  - !ruby/object:Gem::Dependency
350
378
  name: simplecov
351
379
  requirement: !ruby/object:Gem::Requirement
@@ -360,6 +388,20 @@ dependencies:
360
388
  - - "~>"
361
389
  - !ruby/object:Gem::Version
362
390
  version: '0.17'
391
+ - !ruby/object:Gem::Dependency
392
+ name: warning
393
+ requirement: !ruby/object:Gem::Requirement
394
+ requirements:
395
+ - - "~>"
396
+ - !ruby/object:Gem::Version
397
+ version: '1'
398
+ type: :development
399
+ prerelease: false
400
+ version_requirements: !ruby/object:Gem::Requirement
401
+ requirements:
402
+ - - "~>"
403
+ - !ruby/object:Gem::Version
404
+ version: '1'
363
405
  description: |
364
406
  ddtrace is Datadog’s tracing client for Ruby. It is used to trace requests
365
407
  as they flow across web servers, databases and microservices so that developers
@@ -379,6 +421,7 @@ files:
379
421
  - ".circleci/images/primary/Dockerfile-2.5.6"
380
422
  - ".circleci/images/primary/Dockerfile-2.6.4"
381
423
  - ".circleci/images/primary/Dockerfile-2.7.0"
424
+ - ".circleci/images/primary/Dockerfile-3.0.0"
382
425
  - ".circleci/images/primary/Dockerfile-jruby-9.2"
383
426
  - ".dockerignore"
384
427
  - ".env"
@@ -611,6 +654,12 @@ files:
611
654
  - lib/ddtrace/contrib/presto/instrumentation.rb
612
655
  - lib/ddtrace/contrib/presto/integration.rb
613
656
  - lib/ddtrace/contrib/presto/patcher.rb
657
+ - lib/ddtrace/contrib/qless/configuration/settings.rb
658
+ - lib/ddtrace/contrib/qless/ext.rb
659
+ - lib/ddtrace/contrib/qless/integration.rb
660
+ - lib/ddtrace/contrib/qless/patcher.rb
661
+ - lib/ddtrace/contrib/qless/qless_job.rb
662
+ - lib/ddtrace/contrib/qless/tracer_cleaner.rb
614
663
  - lib/ddtrace/contrib/que/configuration/settings.rb
615
664
  - lib/ddtrace/contrib/que/ext.rb
616
665
  - lib/ddtrace/contrib/que/integration.rb
@@ -839,7 +888,7 @@ licenses:
839
888
  - BSD-3-Clause
840
889
  metadata:
841
890
  allowed_push_host: https://rubygems.org
842
- post_install_message:
891
+ post_install_message:
843
892
  rdoc_options: []
844
893
  require_paths:
845
894
  - lib
@@ -854,9 +903,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
854
903
  - !ruby/object:Gem::Version
855
904
  version: 2.0.0
856
905
  requirements: []
857
- rubyforge_project:
858
- rubygems_version: 2.2.5
859
- signing_key:
906
+ rubygems_version: 3.2.3
907
+ signing_key:
860
908
  specification_version: 4
861
909
  summary: Datadog tracing code for your Ruby applications
862
910
  test_files: []