ddtrace 0.44.0 → 0.45.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +48 -1
  3. data/Appraisals +16 -7
  4. data/CHANGELOG.md +43 -1
  5. data/README.md +1 -0
  6. data/Rakefile +51 -2
  7. data/ddtrace.gemspec +1 -0
  8. data/docs/GettingStarted.md +65 -6
  9. data/lib/ddtrace.rb +7 -0
  10. data/lib/ddtrace/auto_instrument.rb +3 -0
  11. data/lib/ddtrace/auto_instrument_base.rb +6 -0
  12. data/lib/ddtrace/contrib/action_cable/integration.rb +7 -0
  13. data/lib/ddtrace/contrib/action_pack/integration.rb +7 -0
  14. data/lib/ddtrace/contrib/action_view/integration.rb +7 -0
  15. data/lib/ddtrace/contrib/active_record/integration.rb +7 -0
  16. data/lib/ddtrace/contrib/active_record/utils.rb +56 -20
  17. data/lib/ddtrace/contrib/active_support/integration.rb +7 -1
  18. data/lib/ddtrace/contrib/auto_instrument.rb +48 -0
  19. data/lib/ddtrace/contrib/cucumber/integration.rb +5 -0
  20. data/lib/ddtrace/contrib/ethon/easy_patch.rb +5 -4
  21. data/lib/ddtrace/contrib/extensions.rb +27 -1
  22. data/lib/ddtrace/contrib/httpclient/configuration/settings.rb +32 -0
  23. data/lib/ddtrace/contrib/httpclient/ext.rb +17 -0
  24. data/lib/ddtrace/contrib/httpclient/instrumentation.rb +152 -0
  25. data/lib/ddtrace/contrib/httpclient/integration.rb +43 -0
  26. data/lib/ddtrace/contrib/httpclient/patcher.rb +35 -0
  27. data/lib/ddtrace/contrib/patchable.rb +18 -7
  28. data/lib/ddtrace/contrib/rack/integration.rb +7 -0
  29. data/lib/ddtrace/contrib/rack/middlewares.rb +1 -1
  30. data/lib/ddtrace/contrib/rack/request_queue.rb +6 -1
  31. data/lib/ddtrace/contrib/rails/auto_instrument_railtie.rb +10 -0
  32. data/lib/ddtrace/contrib/rails/utils.rb +4 -0
  33. data/lib/ddtrace/contrib/rake/integration.rb +1 -1
  34. data/lib/ddtrace/contrib/rspec/integration.rb +5 -0
  35. data/lib/ddtrace/ext/ci.rb +42 -9
  36. data/lib/ddtrace/ext/git.rb +0 -1
  37. data/lib/ddtrace/propagation/http_propagator.rb +17 -2
  38. data/lib/ddtrace/version.rb +1 -1
  39. metadata +29 -6
@@ -18,7 +18,7 @@ module Datadog
18
18
  end
19
19
 
20
20
  def self.loaded?
21
- !defined?(::Rake).nil?
21
+ !defined?(::Rake::Task).nil?
22
22
  end
23
23
 
24
24
  def self.compatible?
@@ -28,6 +28,11 @@ module Datadog
28
28
  super && version >= MINIMUM_VERSION
29
29
  end
30
30
 
31
+ # test environments should not auto instrument test libraries
32
+ def auto_instrument?
33
+ false
34
+ end
35
+
31
36
  def default_configuration
32
37
  Configuration::Settings.new
33
38
  end
@@ -5,6 +5,8 @@ module Datadog
5
5
  # Defines constants for CI tags
6
6
  # rubocop:disable Metrics/ModuleLength:
7
7
  module CI
8
+ TAG_STAGE_NAME = 'ci.stage.name'.freeze
9
+ TAG_JOB_NAME = 'ci.job.name'.freeze
8
10
  TAG_JOB_URL = 'ci.job.url'.freeze
9
11
  TAG_PIPELINE_ID = 'ci.pipeline.id'.freeze
10
12
  TAG_PIPELINE_NAME = 'ci.pipeline.name'.freeze
@@ -23,7 +25,8 @@ module Datadog
23
25
  ['GITLAB_CI'.freeze, :extract_gitlab],
24
26
  ['JENKINS_URL'.freeze, :extract_jenkins],
25
27
  ['TEAMCITY_VERSION'.freeze, :extract_teamcity],
26
- ['TRAVIS'.freeze, :extract_travis]
28
+ ['TRAVIS'.freeze, :extract_travis],
29
+ ['BITRISE_BUILD_SLUG'.freeze, :extract_bitrise]
27
30
  ].freeze
28
31
 
29
32
  module_function
@@ -37,7 +40,6 @@ module Datadog
37
40
  tags[Git::TAG_TAG] = normalize_ref(tags[Git::TAG_TAG])
38
41
  tags.delete(Git::TAG_BRANCH) unless tags[Git::TAG_TAG].nil?
39
42
  tags[Git::TAG_BRANCH] = normalize_ref(tags[Git::TAG_BRANCH])
40
- tags[Git::TAG_DEPRECATED_COMMIT_SHA] = tags[Git::TAG_COMMIT_SHA]
41
43
  tags[Git::TAG_REPOSITORY_URL] = filter_sensitive_info(tags[Git::TAG_REPOSITORY_URL])
42
44
 
43
45
  # Expand ~
@@ -63,26 +65,34 @@ module Datadog
63
65
 
64
66
  def extract_appveyor(env)
65
67
  url = "https://ci.appveyor.com/project/#{env['APPVEYOR_REPO_NAME']}/builds/#{env['APPVEYOR_BUILD_ID']}"
68
+
69
+ if env['APPVEYOR_REPO_PROVIDER'] == 'github'
70
+ repository = "https://github.com/#{env['APPVEYOR_REPO_NAME']}.git"
71
+ commit = env['APPVEYOR_REPO_COMMIT']
72
+ branch = (env['APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH'] || env['APPVEYOR_REPO_BRANCH'])
73
+ tag = env['APPVEYOR_REPO_TAG_NAME']
74
+ end
75
+
66
76
  {
67
77
  TAG_PROVIDER_NAME => 'appveyor',
68
- Git::TAG_REPOSITORY_URL => "https://github.com/#{env['APPVEYOR_REPO_NAME']}.git",
69
- Git::TAG_COMMIT_SHA => env['APPVEYOR_REPO_COMMIT'],
78
+ Git::TAG_REPOSITORY_URL => repository,
79
+ Git::TAG_COMMIT_SHA => commit,
70
80
  TAG_WORKSPACE_PATH => env['APPVEYOR_BUILD_FOLDER'],
71
81
  TAG_PIPELINE_ID => env['APPVEYOR_BUILD_ID'],
72
82
  TAG_PIPELINE_NAME => env['APPVEYOR_REPO_NAME'],
73
83
  TAG_PIPELINE_NUMBER => env['APPVEYOR_BUILD_NUMBER'],
74
84
  TAG_PIPELINE_URL => url,
75
85
  TAG_JOB_URL => url,
76
- Git::TAG_BRANCH => (env['APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH'] || env['APPVEYOR_REPO_BRANCH']),
77
- Git::TAG_TAG => env['APPVEYOR_REPO_TAG_NAME']
86
+ Git::TAG_BRANCH => branch,
87
+ Git::TAG_TAG => tag
78
88
  }
79
89
  end
80
90
 
81
91
  def extract_azure_pipelines(env)
82
- if env['SYSTEM_TEAMFOUNDATIONSERVERURI'] && env['SYSTEM_TEAMPROJECT'] && env['BUILD_BUILDID']
83
- base_url = "#{env['SYSTEM_TEAMFOUNDATIONSERVERURI']}#{env['SYSTEM_TEAMPROJECT']}" \
92
+ if env['SYSTEM_TEAMFOUNDATIONSERVERURI'] && env['SYSTEM_TEAMPROJECTID'] && env['BUILD_BUILDID']
93
+ base_url = "#{env['SYSTEM_TEAMFOUNDATIONSERVERURI']}#{env['SYSTEM_TEAMPROJECTID']}" \
84
94
  "/_build/results?buildId=#{env['BUILD_BUILDID']}"
85
- pipeline_url = base_url + '&_a=summary'
95
+ pipeline_url = base_url
86
96
  job_url = base_url + "&view=logs&j=#{env['SYSTEM_JOBID']}&t=#{env['SYSTEM_TASKINSTANCEID']}"
87
97
  else
88
98
  pipeline_url = job_url = nil
@@ -194,6 +204,8 @@ module Datadog
194
204
  Git::TAG_COMMIT_SHA => env['CI_COMMIT_SHA'],
195
205
  Git::TAG_REPOSITORY_URL => env['CI_REPOSITORY_URL'],
196
206
  Git::TAG_TAG => env['CI_COMMIT_TAG'],
207
+ TAG_STAGE_NAME => env['CI_JOB_STAGE'],
208
+ TAG_JOB_NAME => env['CI_JOB_NAME'],
197
209
  TAG_JOB_URL => env['CI_JOB_URL'],
198
210
  TAG_PIPELINE_ID => env['CI_PIPELINE_ID'],
199
211
  TAG_PIPELINE_NAME => env['CI_PROJECT_PATH'],
@@ -259,6 +271,27 @@ module Datadog
259
271
  TAG_WORKSPACE_PATH => env['TRAVIS_BUILD_DIR']
260
272
  }
261
273
  end
274
+
275
+ def extract_bitrise(env)
276
+ commit = (
277
+ env['BITRISE_GIT_COMMIT'] || env['GIT_CLONE_COMMIT_HASH']
278
+ )
279
+ branch = (
280
+ env['BITRISEIO_GIT_BRANCH_DEST'] || env['BITRISE_GIT_BRANCH']
281
+ )
282
+ {
283
+ TAG_PROVIDER_NAME => 'bitrise',
284
+ TAG_PIPELINE_ID => env['BITRISE_BUILD_SLUG'],
285
+ TAG_PIPELINE_NAME => env['BITRISE_APP_TITLE'],
286
+ TAG_PIPELINE_NUMBER => env['BITRISE_BUILD_NUMBER'],
287
+ TAG_PIPELINE_URL => env['BITRISE_BUILD_URL'],
288
+ TAG_WORKSPACE_PATH => env['BITRISE_SOURCE_DIR'],
289
+ Git::TAG_REPOSITORY_URL => env['GIT_REPOSITORY_URL'],
290
+ Git::TAG_COMMIT_SHA => commit,
291
+ Git::TAG_BRANCH => branch,
292
+ Git::TAG_TAG => env['BITRISE_GIT_TAG']
293
+ }
294
+ end
262
295
  end
263
296
  end
264
297
  end
@@ -4,7 +4,6 @@ module Datadog
4
4
  module Git
5
5
  TAG_BRANCH = 'git.branch'.freeze
6
6
  TAG_COMMIT_SHA = 'git.commit.sha'.freeze
7
- TAG_DEPRECATED_COMMIT_SHA = 'git.commit_sha'.freeze
8
7
  TAG_REPOSITORY_URL = 'git.repository_url'.freeze
9
8
  TAG_TAG = 'git.tag'.freeze
10
9
  end
@@ -26,7 +26,14 @@ module Datadog
26
26
  # Inject all configured propagation styles
27
27
  ::Datadog.configuration.distributed_tracing.propagation_inject_style.each do |style|
28
28
  propagator = PROPAGATION_STYLES[style]
29
- propagator.inject!(context, env) unless propagator.nil?
29
+ begin
30
+ propagator.inject!(context, env) unless propagator.nil?
31
+ rescue => e
32
+ Datadog.logger.error(
33
+ 'Error injecting propagated context into the environment. ' \
34
+ "Cause: #{e} Location: #{e.backtrace.first}"
35
+ )
36
+ end
30
37
  end
31
38
  end
32
39
 
@@ -42,7 +49,15 @@ module Datadog
42
49
 
43
50
  # Extract context
44
51
  # DEV: `propagator.extract` will return `nil`, where `HTTPPropagator#extract` will not
45
- extracted_context = propagator.extract(env)
52
+ begin
53
+ extracted_context = propagator.extract(env)
54
+ rescue => e
55
+ Datadog.logger.error(
56
+ 'Error extracting propagated context from the environment. ' \
57
+ "Cause: #{e} Location: #{e.backtrace.first}"
58
+ )
59
+ end
60
+
46
61
  # Skip this style if no valid headers were found
47
62
  next if extracted_context.nil?
48
63
 
@@ -1,7 +1,7 @@
1
1
  module Datadog
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 44
4
+ MINOR = 45
5
5
  PATCH = 0
6
6
  PRE = nil
7
7
 
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.44.0
4
+ version: 0.45.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: 2021-01-06 00:00:00.000000000 Z
11
+ date: 2021-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -262,6 +262,20 @@ dependencies:
262
262
  - - "~>"
263
263
  - !ruby/object:Gem::Version
264
264
  version: 0.2.0
265
+ - !ruby/object:Gem::Dependency
266
+ name: rspec_junit_formatter
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - ">="
270
+ - !ruby/object:Gem::Version
271
+ version: 0.4.1
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - ">="
277
+ - !ruby/object:Gem::Version
278
+ version: 0.4.1
265
279
  - !ruby/object:Gem::Dependency
266
280
  name: addressable
267
281
  requirement: !ruby/object:Gem::Requirement
@@ -456,6 +470,8 @@ files:
456
470
  - lib/ddtrace/augmentation/method_wrapper.rb
457
471
  - lib/ddtrace/augmentation/method_wrapping.rb
458
472
  - lib/ddtrace/augmentation/shim.rb
473
+ - lib/ddtrace/auto_instrument.rb
474
+ - lib/ddtrace/auto_instrument_base.rb
459
475
  - lib/ddtrace/buffer.rb
460
476
  - lib/ddtrace/chunker.rb
461
477
  - lib/ddtrace/configuration.rb
@@ -529,6 +545,7 @@ files:
529
545
  - lib/ddtrace/contrib/active_support/notifications/subscription.rb
530
546
  - lib/ddtrace/contrib/active_support/patcher.rb
531
547
  - lib/ddtrace/contrib/analytics.rb
548
+ - lib/ddtrace/contrib/auto_instrument.rb
532
549
  - lib/ddtrace/contrib/aws/configuration/settings.rb
533
550
  - lib/ddtrace/contrib/aws/ext.rb
534
551
  - lib/ddtrace/contrib/aws/instrumentation.rb
@@ -612,6 +629,11 @@ files:
612
629
  - lib/ddtrace/contrib/http/integration.rb
613
630
  - lib/ddtrace/contrib/http/patcher.rb
614
631
  - lib/ddtrace/contrib/http_annotation_helper.rb
632
+ - lib/ddtrace/contrib/httpclient/configuration/settings.rb
633
+ - lib/ddtrace/contrib/httpclient/ext.rb
634
+ - lib/ddtrace/contrib/httpclient/instrumentation.rb
635
+ - lib/ddtrace/contrib/httpclient/integration.rb
636
+ - lib/ddtrace/contrib/httpclient/patcher.rb
615
637
  - lib/ddtrace/contrib/httprb/configuration/settings.rb
616
638
  - lib/ddtrace/contrib/httprb/ext.rb
617
639
  - lib/ddtrace/contrib/httprb/instrumentation.rb
@@ -680,6 +702,7 @@ files:
680
702
  - lib/ddtrace/contrib/rack/middlewares.rb
681
703
  - lib/ddtrace/contrib/rack/patcher.rb
682
704
  - lib/ddtrace/contrib/rack/request_queue.rb
705
+ - lib/ddtrace/contrib/rails/auto_instrument_railtie.rb
683
706
  - lib/ddtrace/contrib/rails/configuration/settings.rb
684
707
  - lib/ddtrace/contrib/rails/ext.rb
685
708
  - lib/ddtrace/contrib/rails/framework.rb
@@ -888,7 +911,7 @@ licenses:
888
911
  - BSD-3-Clause
889
912
  metadata:
890
913
  allowed_push_host: https://rubygems.org
891
- post_install_message:
914
+ post_install_message:
892
915
  rdoc_options: []
893
916
  require_paths:
894
917
  - lib
@@ -903,8 +926,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
903
926
  - !ruby/object:Gem::Version
904
927
  version: 2.0.0
905
928
  requirements: []
906
- rubygems_version: 3.2.3
907
- signing_key:
929
+ rubygems_version: 3.1.2
930
+ signing_key:
908
931
  specification_version: 4
909
932
  summary: Datadog tracing code for your Ruby applications
910
933
  test_files: []