ddtrace 0.43.0 → 0.45.0

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 (67) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +148 -130
  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 +215 -14
  7. data/CHANGELOG.md +1048 -377
  8. data/Gemfile +4 -2
  9. data/README.md +1 -0
  10. data/Rakefile +172 -6
  11. data/ddtrace.gemspec +6 -8
  12. data/docker-compose.yml +30 -0
  13. data/docs/GettingStarted.md +112 -14
  14. data/lib/ddtrace.rb +8 -0
  15. data/lib/ddtrace/auto_instrument.rb +3 -0
  16. data/lib/ddtrace/auto_instrument_base.rb +6 -0
  17. data/lib/ddtrace/contrib/action_cable/integration.rb +7 -0
  18. data/lib/ddtrace/contrib/action_pack/integration.rb +7 -0
  19. data/lib/ddtrace/contrib/action_view/event.rb +0 -4
  20. data/lib/ddtrace/contrib/action_view/events/render_partial.rb +1 -0
  21. data/lib/ddtrace/contrib/action_view/events/render_template.rb +1 -0
  22. data/lib/ddtrace/contrib/action_view/integration.rb +7 -0
  23. data/lib/ddtrace/contrib/active_record/integration.rb +7 -0
  24. data/lib/ddtrace/contrib/active_record/utils.rb +67 -21
  25. data/lib/ddtrace/contrib/active_support/integration.rb +7 -1
  26. data/lib/ddtrace/contrib/auto_instrument.rb +48 -0
  27. data/lib/ddtrace/contrib/aws/services.rb +1 -0
  28. data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +2 -0
  29. data/lib/ddtrace/contrib/cucumber/integration.rb +5 -0
  30. data/lib/ddtrace/contrib/ethon/easy_patch.rb +6 -5
  31. data/lib/ddtrace/contrib/ethon/ext.rb +1 -0
  32. data/lib/ddtrace/contrib/extensions.rb +27 -1
  33. data/lib/ddtrace/contrib/grape/endpoint.rb +29 -11
  34. data/lib/ddtrace/contrib/grape/ext.rb +1 -0
  35. data/lib/ddtrace/contrib/httpclient/configuration/settings.rb +32 -0
  36. data/lib/ddtrace/contrib/httpclient/ext.rb +17 -0
  37. data/lib/ddtrace/contrib/httpclient/instrumentation.rb +152 -0
  38. data/lib/ddtrace/contrib/httpclient/integration.rb +43 -0
  39. data/lib/ddtrace/contrib/httpclient/patcher.rb +35 -0
  40. data/lib/ddtrace/contrib/httprb/instrumentation.rb +1 -1
  41. data/lib/ddtrace/contrib/patchable.rb +18 -7
  42. data/lib/ddtrace/contrib/qless/configuration/settings.rb +35 -0
  43. data/lib/ddtrace/contrib/qless/ext.rb +20 -0
  44. data/lib/ddtrace/contrib/qless/integration.rb +38 -0
  45. data/lib/ddtrace/contrib/qless/patcher.rb +35 -0
  46. data/lib/ddtrace/contrib/qless/qless_job.rb +72 -0
  47. data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +32 -0
  48. data/lib/ddtrace/contrib/rack/integration.rb +7 -0
  49. data/lib/ddtrace/contrib/rack/middlewares.rb +1 -1
  50. data/lib/ddtrace/contrib/rack/request_queue.rb +6 -1
  51. data/lib/ddtrace/contrib/rails/auto_instrument_railtie.rb +10 -0
  52. data/lib/ddtrace/contrib/rails/utils.rb +4 -0
  53. data/lib/ddtrace/contrib/rake/integration.rb +1 -1
  54. data/lib/ddtrace/contrib/redis/configuration/resolver.rb +3 -1
  55. data/lib/ddtrace/contrib/redis/configuration/settings.rb +5 -0
  56. data/lib/ddtrace/contrib/redis/ext.rb +1 -0
  57. data/lib/ddtrace/contrib/redis/patcher.rb +20 -3
  58. data/lib/ddtrace/contrib/redis/quantize.rb +27 -0
  59. data/lib/ddtrace/contrib/redis/tags.rb +5 -1
  60. data/lib/ddtrace/contrib/rspec/integration.rb +5 -0
  61. data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +2 -2
  62. data/lib/ddtrace/ext/ci.rb +42 -10
  63. data/lib/ddtrace/ext/git.rb +0 -1
  64. data/lib/ddtrace/propagation/http_propagator.rb +17 -2
  65. data/lib/ddtrace/version.rb +1 -1
  66. data/lib/ddtrace/workers/runtime_metrics.rb +7 -3
  67. metadata +91 -20
@@ -0,0 +1,32 @@
1
+ module Datadog
2
+ module Contrib
3
+ module Qless
4
+ # Shutdown Tracer in forks for performance reasons
5
+ module TracerCleaner
6
+ def around_perform(job)
7
+ return super unless datadog_configuration && tracer
8
+
9
+ super.tap do
10
+ tracer.shutdown! if forked?
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def forked?
17
+ pin = Datadog::Pin.get_from(::Qless)
18
+ return false unless pin
19
+ pin.config[:forked] == true
20
+ end
21
+
22
+ def tracer
23
+ datadog_configuration.tracer
24
+ end
25
+
26
+ def datadog_configuration
27
+ Datadog.configuration[:qless]
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,6 +1,7 @@
1
1
  require 'ddtrace/contrib/integration'
2
2
  require 'ddtrace/contrib/rack/configuration/settings'
3
3
  require 'ddtrace/contrib/rack/patcher'
4
+ require 'ddtrace/contrib/rails/utils'
4
5
 
5
6
  module Datadog
6
7
  module Contrib
@@ -25,6 +26,12 @@ module Datadog
25
26
  super && version >= MINIMUM_VERSION
26
27
  end
27
28
 
29
+ # enabled by rails integration so should only auto instrument
30
+ # if detected that it is being used without rails
31
+ def auto_instrument?
32
+ !Datadog::Contrib::Rails::Utils.railtie_supported?
33
+ end
34
+
28
35
  def default_configuration
29
36
  Configuration::Settings.new
30
37
  end
@@ -53,7 +53,7 @@ module Datadog
53
53
  tracer.provider.context = context if context.trace_id
54
54
  end
55
55
 
56
- # [experimental] create a root Span to keep track of frontend web servers
56
+ # Create a root Span to keep track of frontend web servers
57
57
  # (i.e. Apache, nginx) if the header is properly set
58
58
  frontend_span = compute_queue_time(env, tracer)
59
59
 
@@ -1,7 +1,12 @@
1
1
  module Datadog
2
2
  module Contrib
3
3
  module Rack
4
- # QueueTime simply...
4
+ # Retrieves the time spent in an upstream proxy
5
+ # for the current Rack request.
6
+ #
7
+ # This time captures the request delay introduced but
8
+ # such proxy before the request made it to the Ruby
9
+ # process.
5
10
  module QueueTime
6
11
  REQUEST_START = 'HTTP_X_REQUEST_START'.freeze
7
12
  QUEUE_START = 'HTTP_X_QUEUE_START'.freeze
@@ -0,0 +1,10 @@
1
+ require 'ddtrace'
2
+
3
+ # Railtie to include AutoInstrumentation in rails loading
4
+ class DatadogAutoInstrumentRailtie < Rails::Railtie
5
+ # we want to load before config initializers so that any user supplied config
6
+ # in config/initializers/datadog.rb will take precedence
7
+ initializer 'datadog.start_tracer', before: :load_config_initializers do
8
+ Datadog::Contrib::AutoInstrument.patch_all
9
+ end
10
+ end
@@ -14,6 +14,10 @@ module Datadog
14
14
  ::Rails.application.class.to_s.underscore
15
15
  end
16
16
  end
17
+
18
+ def self.railtie_supported?
19
+ !(defined?(::Rails::VERSION::MAJOR) && ::Rails::VERSION::MAJOR >= 3 && defined?(::Rails::Railtie)).nil?
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -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?
@@ -4,6 +4,8 @@ module Datadog
4
4
  module Contrib
5
5
  module Redis
6
6
  module Configuration
7
+ UNIX_SCHEME = 'unix'.freeze
8
+
7
9
  # Converts Symbols, Strings, and Hashes to a normalized connection settings Hash.
8
10
  class Resolver < Contrib::Configuration::Resolver
9
11
  def resolve(key_or_hash)
@@ -13,7 +15,7 @@ module Datadog
13
15
  end
14
16
 
15
17
  def normalize(hash)
16
- return { url: hash[:url] } if hash[:scheme] == 'unix'
18
+ return { url: hash[:url] } if hash[:scheme] == UNIX_SCHEME
17
19
 
18
20
  # Connexion strings are always converted to host, port, db and scheme
19
21
  # but the host, port, db and scheme will generate the :url only after
@@ -22,6 +22,11 @@ module Datadog
22
22
  o.lazy
23
23
  end
24
24
 
25
+ option :command_args do |o|
26
+ o.default { env_to_bool(Ext::ENV_COMMAND_ARGS, true) }
27
+ o.lazy
28
+ end
29
+
25
30
  option :service_name, default: Ext::SERVICE_NAME
26
31
  end
27
32
  end
@@ -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
@@ -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
@@ -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
@@ -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'],
@@ -221,7 +233,6 @@ module Datadog
221
233
  Git::TAG_COMMIT_SHA => env['GIT_COMMIT'],
222
234
  Git::TAG_REPOSITORY_URL => env['GIT_URL'],
223
235
  Git::TAG_TAG => tag,
224
- TAG_JOB_URL => env['JOB_URL'],
225
236
  TAG_PIPELINE_ID => env['BUILD_TAG'],
226
237
  TAG_PIPELINE_NAME => name,
227
238
  TAG_PIPELINE_NUMBER => env['BUILD_NUMBER'],
@@ -260,6 +271,27 @@ module Datadog
260
271
  TAG_WORKSPACE_PATH => env['TRAVIS_BUILD_DIR']
261
272
  }
262
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
263
295
  end
264
296
  end
265
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