ddtrace 1.13.1 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77f5ce82c1888cc91b59b92651e262367f416298b668da0ed48ff06ec6f6fb49
4
- data.tar.gz: 17857f0840b31f08f505661bf07764c79a507e670ef6d378e8bc2688b6be13eb
3
+ metadata.gz: ae7238650b45da9d8bf8f5834af2a29153081e798c2c8733c9bffb8768b6c430
4
+ data.tar.gz: b9bc8f36d37b91d18754892bd8dbc92cd515b9e38caf8561e23b665f14ee5e9e
5
5
  SHA512:
6
- metadata.gz: cbfce752c4991fe0d71df92527eb3774483dbd4a669d6ff21e3483e2e4dd5caeb0da2a350fb09fd074639c9bdf032dfc166e2e1f60c8493eb98a45e14cf6d523
7
- data.tar.gz: 83de702f81507366ac6afdc37b26df8e1b2df8e283a195e5e8ed5088871e0b3f7ab3035519c3cebd1f15e09935c54119e6093e3d3da010429468a6ecb4710841
6
+ metadata.gz: 4b4cdffa9d4ee39e6763be4a87dbdf3e351fd29915d4eaea45dc9c800543c65c8eb21375138422280cfed5715d8f23e95e58190752af6631c14453d39b29b263
7
+ data.tar.gz: fbc970e48e5e5038775368618e672ab7b2405cd6ea9b899136b34e9ae776f26a92436087fb0810ef7d66574c2f694cdea03197cf980b08dc35a9defcf4c3dc74
data/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [1.14.0] - 2023-08-24
6
+
7
+ ### Added
8
+
9
+ * Cucumber 8.0.0 support, test CI visibility with cucumber versions 6-8 ([#3061][])
10
+ * Tracing: Add `ddsource` to #to_log_format ([#3025][])
11
+ * Core: include peer service configurations in telemetry payload ([#3056][])
12
+ * Tracing: Improve quantization ([#3041][])
13
+
14
+ ### Changed
15
+
16
+ * Profiling: Disable profiler on Ruby 3.3 due to incompatibility ([#3054][])
17
+ * Core: EnvironmentLogger adjustments ([#3020][], [#3057][])
18
+
19
+ ### Fixed
20
+
21
+ * Appsec: Fix ASM setting for automated user events. ([#3070][])
22
+ * Tracing: Fix ActiveRecord adapter name for Rails 7 ([#3051][])
23
+
5
24
  ## [1.13.1] - 2023-08-14
6
25
 
7
26
  ### Fixed
@@ -2515,7 +2534,8 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1
2515
2534
 
2516
2535
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
2517
2536
 
2518
- [Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.13.1...master
2537
+ [Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.14.0...master
2538
+ [1.14.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.13.1...1.14.0
2519
2539
  [1.13.1]: https://github.com/DataDog/dd-trace-rb/compare/v1.13.0...1.13.1
2520
2540
  [1.13.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.12.1...v1.13.0
2521
2541
  [1.12.1]: https://github.com/DataDog/dd-trace-rb/compare/v1.12.0...v1.12.1
@@ -3652,12 +3672,21 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
3652
3672
  [#3007]: https://github.com/DataDog/dd-trace-rb/issues/3007
3653
3673
  [#3011]: https://github.com/DataDog/dd-trace-rb/issues/3011
3654
3674
  [#3019]: https://github.com/DataDog/dd-trace-rb/issues/3019
3675
+ [#3020]: https://github.com/DataDog/dd-trace-rb/issues/3020
3655
3676
  [#3022]: https://github.com/DataDog/dd-trace-rb/issues/3022
3677
+ [#3025]: https://github.com/DataDog/dd-trace-rb/issues/3025
3656
3678
  [#3033]: https://github.com/DataDog/dd-trace-rb/issues/3033
3657
3679
  [#3037]: https://github.com/DataDog/dd-trace-rb/issues/3037
3658
3680
  [#3038]: https://github.com/DataDog/dd-trace-rb/issues/3038
3659
3681
  [#3039]: https://github.com/DataDog/dd-trace-rb/issues/3039
3682
+ [#3041]: https://github.com/DataDog/dd-trace-rb/issues/3041
3660
3683
  [#3045]: https://github.com/DataDog/dd-trace-rb/issues/3045
3684
+ [#3051]: https://github.com/DataDog/dd-trace-rb/issues/3051
3685
+ [#3054]: https://github.com/DataDog/dd-trace-rb/issues/3054
3686
+ [#3056]: https://github.com/DataDog/dd-trace-rb/issues/3056
3687
+ [#3057]: https://github.com/DataDog/dd-trace-rb/issues/3057
3688
+ [#3061]: https://github.com/DataDog/dd-trace-rb/issues/3061
3689
+ [#3070]: https://github.com/DataDog/dd-trace-rb/issues/3070
3661
3690
  [@AdrianLC]: https://github.com/AdrianLC
3662
3691
  [@Azure7111]: https://github.com/Azure7111
3663
3692
  [@BabyGroot]: https://github.com/BabyGroot
@@ -87,6 +87,7 @@ module Datadog
87
87
  on_unknown_os? ||
88
88
  on_unsupported_cpu_arch? ||
89
89
  on_unsupported_ruby_version? ||
90
+ on_ruby_3_3? ||
90
91
  expected_to_use_mjit_but_mjit_is_disabled? ||
91
92
  libdatadog_not_available? ||
92
93
  libdatadog_not_usable?
@@ -269,6 +270,20 @@ module Datadog
269
270
  ruby_version_not_supported if RUBY_VERSION.start_with?('2.1.', '2.2.')
270
271
  end
271
272
 
273
+ private_class_method def self.on_ruby_3_3?
274
+ incompatible_with_3_3 = explain_issue(
275
+ 'the profiler in the current version of ddtrace does not yet support',
276
+ 'Ruby version 3.3.',
277
+ '(See https://github.com/datadog/dd-trace-rb/issues/3053 for details).',
278
+ suggested: [
279
+ 'Try upgrading to the latest ddtrace, as this issue may have been',
280
+ 'fixed by now.',
281
+ ] + CONTACT_SUPPORT,
282
+ )
283
+
284
+ incompatible_with_3_3 if RUBY_VERSION.start_with?('3.3.')
285
+ end
286
+
272
287
  # On some Rubies, we require the mjit header to be present. If Ruby was installed without MJIT support, we also skip
273
288
  # building the extension.
274
289
  private_class_method def self.expected_to_use_mjit_but_mjit_is_disabled?
@@ -15,6 +15,10 @@ module Datadog
15
15
  'safe',
16
16
  'extended'
17
17
  ].freeze
18
+ APPSEC_VALID_TRACK_USER_EVENTS_ENABLED_VALUES = [
19
+ '1',
20
+ 'true'
21
+ ].concat(APPSEC_VALID_TRACK_USER_EVENTS_MODE).freeze
18
22
 
19
23
  def self.extended(base)
20
24
  base = base.singleton_class unless base.is_a?(Class)
@@ -100,7 +104,7 @@ module Datadog
100
104
  if env_value == 'disabled'
101
105
  false
102
106
  else
103
- ['1', 'true'].include?(env_value.strip.downcase)
107
+ APPSEC_VALID_TRACK_USER_EVENTS_ENABLED_VALUES.include?(env_value.strip.downcase)
104
108
  end
105
109
  end
106
110
  end
@@ -112,6 +116,8 @@ module Datadog
112
116
  o.setter do |v|
113
117
  if APPSEC_VALID_TRACK_USER_EVENTS_MODE.include?(v)
114
118
  v
119
+ elsif v == 'disabled'
120
+ 'safe'
115
121
  else
116
122
  Datadog.logger.warn(
117
123
  'The appsec.track_user_events.mode value provided is not supported.' \
@@ -110,6 +110,8 @@ module Datadog
110
110
  else
111
111
  @logger.debug('Profiling is disabled')
112
112
  end
113
+
114
+ Core::Diagnostics::EnvironmentLogger.collect_and_log!
113
115
  end
114
116
 
115
117
  # Shuts down all the components in use.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'date'
2
4
  require 'json'
3
5
  require 'rbconfig'
@@ -5,280 +7,174 @@ require 'rbconfig'
5
7
  module Datadog
6
8
  module Core
7
9
  module Diagnostics
8
- # A holistic collection of the environment in which ddtrace is running.
9
- # This logger should allow for easy reporting by users to Datadog support.
10
- #
11
- module EnvironmentLogger
12
- class << self
13
- # Outputs environment information to {Datadog.logger}.
14
- # Executes only once for the lifetime of the program.
15
- def log!(transport_responses)
16
- return if (defined?(@executed) && @executed) || !log?
17
-
18
- @executed = true
19
-
20
- data = EnvironmentCollector.new.collect!(transport_responses)
21
- data.reject! { |_, v| v.nil? } # Remove empty values from hash output
22
-
23
- log_environment!(data.to_json)
24
- log_error!('Agent Error'.freeze, data[:agent_error]) if data[:agent_error]
25
- rescue => e
26
- Datadog.logger.warn("Failed to collect environment information: #{e} Location: #{Array(e.backtrace).first}")
27
- end
28
-
29
- private
30
-
31
- def log_environment!(line)
32
- Datadog.logger.info("DATADOG CONFIGURATION - #{line}")
33
- end
34
-
35
- def log_error!(type, error)
36
- Datadog.logger.warn("DATADOG DIAGNOSTIC - #{type}: #{error}")
37
- end
38
-
39
- # Are we logging the environment data?
40
- def log?
41
- startup_logs_enabled = Datadog.configuration.diagnostics.startup_logs.enabled
42
- if startup_logs_enabled.nil?
43
- !repl? # Suppress logs if we running in a REPL
44
- else
45
- startup_logs_enabled
46
- end
47
- end
48
-
49
- REPL_PROGRAM_NAMES = %w[irb pry].freeze
50
-
51
- def repl?
52
- REPL_PROGRAM_NAMES.include?($PROGRAM_NAME)
53
- end
54
- end
55
- end
56
-
57
- # Collects environment information for diagnostic logging
58
- class EnvironmentCollector
59
- # @return [String] current time in ISO8601 format
60
- def date
61
- DateTime.now.iso8601
62
- end
63
-
64
- # Best portable guess of OS information.
65
- # @return [String] platform string
66
- def os_name
67
- RbConfig::CONFIG['host'.freeze]
10
+ # Base class for EnvironmentLoggers - should allow for easy reporting by users to Datadog support.
11
+ module EnvironmentLogging
12
+ def log_configuration!(prefix, data)
13
+ logger.info("DATADOG CONFIGURATION - #{prefix} - #{data}")
68
14
  end
69
15
 
70
- # @return [String] ddtrace version
71
- def version
72
- DDTrace::VERSION::STRING
16
+ def log_error!(prefix, type, error)
17
+ logger.warn("DATADOG ERROR - #{prefix} - #{type}: #{error}")
73
18
  end
74
19
 
75
- # @return [String] "ruby"
76
- def lang
77
- Core::Environment::Ext::LANG
78
- end
20
+ protected
79
21
 
80
- # Supported Ruby language version.
81
- # Will be distinct from VM version for non-MRI environments.
82
- # @return [String]
83
- def lang_version
84
- Core::Environment::Ext::LANG_VERSION
22
+ def logger
23
+ Datadog.logger
85
24
  end
86
25
 
87
- # @return [String] configured application environment
88
- def env
89
- Datadog.configuration.env
90
- end
26
+ # If logger should log and hasn't logged already, then output environment configuration and possible errors.
27
+ def log_once!
28
+ # Check if already been executed
29
+ return false if (defined?(@executed) && @executed) || !log?
91
30
 
92
- # @return [Boolean, nil]
93
- def enabled
94
- Datadog.configuration.tracing.enabled
95
- end
31
+ yield if block_given?
96
32
 
97
- # @return [String] configured application service name
98
- def service
99
- Datadog.configuration.service
33
+ @executed = true
100
34
  end
101
35
 
102
- # @return [String] configured application version
103
- def dd_version
104
- Datadog.configuration.version
105
- end
106
-
107
- # @return [String, nil] target agent URL for trace flushing
108
- def agent_url
109
- # Retrieve the effect agent URL, regardless of how it was configured
110
- transport = Tracing.send(:tracer).writer.transport
111
-
112
- # return `nil` with IO transport
113
- return unless transport.respond_to?(:client)
114
-
115
- adapter = transport.client.api.adapter
116
- adapter.url
36
+ # Are we logging the environment data?
37
+ def log?
38
+ startup_logs_enabled = Datadog.configuration.diagnostics.startup_logs.enabled
39
+ if startup_logs_enabled.nil?
40
+ !repl? && !rspec? # Suppress logs if we are running in a REPL or rspec
41
+ else
42
+ startup_logs_enabled
43
+ end
117
44
  end
118
45
 
119
- # Error returned by Datadog agent during a tracer flush attempt
120
- # @return [String] concatenated list of transport errors
121
- def agent_error(transport_responses)
122
- error_responses = transport_responses.reject(&:ok?)
46
+ REPL_PROGRAM_NAMES = %w[irb pry].freeze
123
47
 
124
- return nil if error_responses.empty?
125
-
126
- error_responses.map(&:inspect).join(','.freeze)
127
- end
128
-
129
- # @return [Boolean, nil] debug mode enabled in configuration
130
- def debug
131
- !!Datadog.configuration.diagnostics.debug
48
+ def repl?
49
+ REPL_PROGRAM_NAMES.include?($PROGRAM_NAME)
132
50
  end
133
51
 
134
- # @return [Boolean, nil] analytics enabled in configuration
135
- def analytics_enabled
136
- !!Datadog.configuration.tracing.analytics.enabled
52
+ def rspec?
53
+ $PROGRAM_NAME.end_with?('rspec')
137
54
  end
55
+ end
138
56
 
139
- # @return [Numeric, nil] tracer sample rate configured
140
- def sample_rate
141
- sampler = Datadog.configuration.tracing.sampler
142
- return nil unless sampler
57
+ # Collects and logs Core diagnostic information
58
+ module EnvironmentLogger
59
+ extend EnvironmentLogging
143
60
 
144
- sampler.sample_rate(nil) rescue nil
61
+ def self.collect_and_log!
62
+ log_once! do
63
+ data = EnvironmentCollector.collect_config!
64
+ log_configuration!('CORE', data.to_json)
65
+ end
66
+ rescue => e
67
+ logger.warn("Failed to collect core environment information: #{e} Location: #{Array(e.backtrace).first}")
145
68
  end
69
+ end
146
70
 
147
- # DEV: We currently only support SimpleRule instances.
148
- # DEV: These are the most commonly used rules.
149
- # DEV: We should expand support for other rules in the future,
150
- # DEV: although it is tricky to serialize arbitrary rules.
151
- #
152
- # @return [Hash, nil] sample rules configured
153
- def sampling_rules
154
- sampler = Datadog.configuration.tracing.sampler
155
- return nil unless sampler.is_a?(Tracing::Sampling::PrioritySampler) &&
156
- sampler.priority_sampler.is_a?(Tracing::Sampling::RuleSampler)
157
-
158
- sampler.priority_sampler.rules.map do |rule|
159
- next unless rule.is_a?(Tracing::Sampling::SimpleRule)
160
-
71
+ # Collects environment information for Core diagnostic logging
72
+ module EnvironmentCollector
73
+ class << self
74
+ def collect_config!
161
75
  {
162
- name: rule.matcher.name,
163
- service: rule.matcher.service,
164
- sample_rate: rule.sampler.sample_rate(nil)
76
+ date: date,
77
+ os_name: os_name,
78
+ version: version,
79
+ lang: lang,
80
+ lang_version: lang_version,
81
+ env: env,
82
+ service: service,
83
+ dd_version: dd_version,
84
+ debug: debug,
85
+ tags: tags,
86
+ runtime_metrics_enabled: runtime_metrics_enabled,
87
+ vm: vm,
88
+ health_metrics_enabled: health_metrics_enabled
165
89
  }
166
- end.compact
167
- end
168
-
169
- # @return [Hash, nil] concatenated list of global tracer tags configured
170
- def tags
171
- tags = Datadog.configuration.tags
172
- return nil if tags.empty?
90
+ end
173
91
 
174
- hash_serializer(tags)
175
- end
92
+ # @return [String] current time in ISO8601 format
93
+ def date
94
+ DateTime.now.iso8601
95
+ end
176
96
 
177
- # @return [Boolean, nil] runtime metrics enabled in configuration
178
- def runtime_metrics_enabled
179
- Datadog.configuration.runtime_metrics.enabled
180
- end
97
+ # Best portable guess of OS information.
98
+ # @return [String] platform string
99
+ def os_name
100
+ RbConfig::CONFIG['host']
101
+ end
181
102
 
182
- # Concatenated list of integrations activated, with their gem version.
183
- # Example: "rails@6.0.3,rack@2.2.3"
184
- #
185
- # @return [String, nil]
186
- def integrations_loaded
187
- integrations = instrumented_integrations
188
- return if integrations.empty?
103
+ # @return [String] ddtrace version
104
+ def version
105
+ DDTrace::VERSION::STRING
106
+ end
189
107
 
190
- integrations.map { |name, integration| "#{name}@#{integration.class.version}" }.join(','.freeze)
191
- end
108
+ # @return [String] "ruby"
109
+ def lang
110
+ Core::Environment::Ext::LANG
111
+ end
192
112
 
193
- # Ruby VM name and version.
194
- # Examples: "ruby-2.7.1", "jruby-9.2.11.1", "truffleruby-20.1.0"
195
- # @return [String, nil]
196
- def vm
197
- # RUBY_ENGINE_VERSION returns the VM version, which
198
- # will differ from RUBY_VERSION for non-mri VMs.
199
- if defined?(RUBY_ENGINE_VERSION)
200
- "#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}"
201
- else
202
- # Ruby < 2.3 doesn't support RUBY_ENGINE_VERSION
203
- "#{RUBY_ENGINE}-#{RUBY_VERSION}"
113
+ # Supported Ruby language version.
114
+ # Will be distinct from VM version for non-MRI environments.
115
+ # @return [String]
116
+ def lang_version
117
+ Core::Environment::Ext::LANG_VERSION
204
118
  end
205
- end
206
119
 
207
- # @return [Boolean, nil] partial flushing enabled in configuration
208
- def partial_flushing_enabled
209
- !!Datadog.configuration.tracing.partial_flush.enabled
210
- end
120
+ # @return [String] configured application environment
121
+ def env
122
+ Datadog.configuration.env
123
+ end
211
124
 
212
- # @return [Boolean, nil] priority sampling enabled in configuration
213
- def priority_sampling_enabled
214
- !!Datadog.configuration.tracing.priority_sampling
215
- end
125
+ # @return [String] configured application service name
126
+ def service
127
+ Datadog.configuration.service
128
+ end
216
129
 
217
- # @return [Boolean, nil] health metrics enabled in configuration
218
- def health_metrics_enabled
219
- !!Datadog.configuration.diagnostics.health_metrics.enabled
220
- end
130
+ # @return [String] configured application version
131
+ def dd_version
132
+ Datadog.configuration.version
133
+ end
221
134
 
222
- def profiling_enabled
223
- !!Datadog.configuration.profiling.enabled
224
- end
135
+ # @return [Boolean, nil] debug mode enabled in configuration
136
+ def debug
137
+ !!Datadog.configuration.diagnostics.debug
138
+ end
225
139
 
226
- # TODO: Populate when automatic log correlation is implemented
227
- # def logs_correlation_enabled
228
- # end
140
+ # @return [Hash, nil] concatenated list of global tracer tags configured
141
+ def tags
142
+ tags = Datadog.configuration.tags
143
+ return nil if tags.empty?
229
144
 
230
- # @return [Hash] environment information available at call time
231
- def collect!(transport_responses)
232
- {
233
- date: date,
234
- os_name: os_name,
235
- version: version,
236
- lang: lang,
237
- lang_version: lang_version,
238
- env: env,
239
- enabled: enabled,
240
- service: service,
241
- dd_version: dd_version,
242
- agent_url: agent_url,
243
- agent_error: agent_error(transport_responses),
244
- debug: debug,
245
- analytics_enabled: analytics_enabled,
246
- sample_rate: sample_rate,
247
- sampling_rules: sampling_rules,
248
- tags: tags,
249
- runtime_metrics_enabled: runtime_metrics_enabled,
250
- integrations_loaded: integrations_loaded,
251
- vm: vm,
252
- partial_flushing_enabled: partial_flushing_enabled,
253
- priority_sampling_enabled: priority_sampling_enabled,
254
- health_metrics_enabled: health_metrics_enabled,
255
- profiling_enabled: profiling_enabled,
256
- **instrumented_integrations_settings
257
- }
258
- end
145
+ hash_serializer(tags)
146
+ end
259
147
 
260
- private
148
+ # @return [Boolean, nil] runtime metrics enabled in configuration
149
+ def runtime_metrics_enabled
150
+ Datadog.configuration.runtime_metrics.enabled
151
+ end
261
152
 
262
- def instrumented_integrations
263
- Datadog.configuration.tracing.instrumented_integrations
264
- end
153
+ # Ruby VM name and version.
154
+ # Examples: "ruby-2.7.1", "jruby-9.2.11.1", "truffleruby-20.1.0"
155
+ # @return [String, nil]
156
+ def vm
157
+ # RUBY_ENGINE_VERSION returns the VM version, which
158
+ # will differ from RUBY_VERSION for non-mri VMs.
159
+ if defined?(RUBY_ENGINE_VERSION)
160
+ "#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}"
161
+ else
162
+ # Ruby < 2.3 doesn't support RUBY_ENGINE_VERSION
163
+ "#{RUBY_ENGINE}-#{RUBY_VERSION}"
164
+ end
165
+ end
265
166
 
266
- # Capture all active integration settings into "integrationName_settingName: value" entries.
267
- def instrumented_integrations_settings
268
- instrumented_integrations.flat_map do |name, integration|
269
- integration.configuration.to_h.flat_map do |setting, value|
270
- next [] if setting == :tracer # Skip internal Ruby objects
167
+ # @return [Boolean, nil] health metrics enabled in configuration
168
+ def health_metrics_enabled
169
+ !!Datadog.configuration.diagnostics.health_metrics.enabled
170
+ end
271
171
 
272
- # Convert value to a string to avoid custom #to_json
273
- # handlers possibly causing errors.
274
- [[:"integration_#{name}_#{setting}", value.to_s]]
275
- end
276
- end.to_h
277
- end
172
+ private
278
173
 
279
- # Outputs "k1:v1,k2:v2,..."
280
- def hash_serializer(h)
281
- h.map { |k, v| "#{k}:#{v}" }.join(','.freeze)
174
+ # Outputs "k1:v1,k2:v2,..."
175
+ def hash_serializer(h)
176
+ h.map { |k, v| "#{k}:#{v}" }.join(',')
177
+ end
282
178
  end
283
179
  end
284
180
  end
@@ -10,7 +10,7 @@ module Datadog
10
10
  # This can be used to make decisions about when to enable
11
11
  # background systems like worker threads or telemetry.
12
12
  def development?
13
- !!(repl? || test?)
13
+ !!(repl? || test? || rails_development?)
14
14
  end
15
15
 
16
16
  private
@@ -48,6 +48,16 @@ module Datadog
48
48
  ::Minitest::Unit.class_variable_defined?(:@@installed_at_exit) &&
49
49
  ::Minitest::Unit.class_variable_get(:@@installed_at_exit))
50
50
  end
51
+
52
+ # A Rails Spring Ruby process is a bit peculiar: the process is agnostic
53
+ # whether the application is running as a console or server.
54
+ # Luckily, the Spring gem *must not* be installed in a production environment so
55
+ # detecting its presence is enough to deduct if this is a development environment.
56
+ #
57
+ # @see https://github.com/rails/spring/blob/48b299348ace2188444489a0c216a6f3e9687281/README.md?plain=1#L204-L207
58
+ def rails_development?
59
+ defined?(::Spring)
60
+ end
51
61
  end
52
62
  end
53
63
  end
@@ -43,11 +43,19 @@ module Datadog
43
43
 
44
44
  # Forms a hash of standard key value pairs to be sent in the app-started event configuration
45
45
  def configurations
46
+ config = Datadog.configuration
46
47
  hash = {
47
- DD_AGENT_HOST: Datadog.configuration.agent.host,
48
+ DD_AGENT_HOST: config.agent.host,
48
49
  DD_AGENT_TRANSPORT: agent_transport,
49
- DD_TRACE_SAMPLE_RATE: format_configuration_value(Datadog.configuration.tracing.sampling.default_rate),
50
+ DD_TRACE_SAMPLE_RATE: format_configuration_value(config.tracing.sampling.default_rate),
51
+ DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED: config.tracing.contrib.global_default_service_name.enabled
50
52
  }
53
+ peer_service_mapping_str = ''
54
+ unless config.tracing.contrib.peer_service_mapping.empty?
55
+ peer_service_mapping = config.tracing.contrib.peer_service_mapping
56
+ peer_service_mapping_str = peer_service_mapping.map { |key, value| "#{key}:#{value}" }.join(',')
57
+ end
58
+ hash[:DD_TRACE_PEER_SERVICE_MAPPING] = peer_service_mapping_str
51
59
  hash.compact!
52
60
  hash
53
61
  end
@@ -8,6 +8,9 @@ module Datadog
8
8
  # * Code Hotspots panel in the trace viewer, as well as scoping a profile down to a span
9
9
  # * Endpoint aggregation in the profiler UX, including normalization (resource per endpoint call)
10
10
  def self.build_profiler_component(settings:, agent_settings:, optional_tracer:) # rubocop:disable Metrics/MethodLength
11
+ require_relative '../profiling/diagnostics/environment_logger'
12
+ Profiling::Diagnostics::EnvironmentLogger.collect_and_log!
13
+
11
14
  return unless settings.profiling.enabled
12
15
 
13
16
  # Workaround for weird dependency direction: the Core::Configuration::Components class currently has a
@@ -65,9 +68,11 @@ module Datadog
65
68
  # NOTE: Please update the Initialization section of ProfilingDevelopment.md with any changes to this method
66
69
 
67
70
  no_signals_workaround_enabled = false
71
+ timeline_enabled = false
68
72
 
69
73
  if enable_new_profiler?(settings)
70
74
  no_signals_workaround_enabled = no_signals_workaround_enabled?(settings)
75
+ timeline_enabled = settings.profiling.advanced.experimental_timeline_enabled
71
76
 
72
77
  recorder = Datadog::Profiling::StackRecorder.new(
73
78
  cpu_time_enabled: RUBY_PLATFORM.include?('linux'), # Only supported on Linux currently
@@ -81,7 +86,7 @@ module Datadog
81
86
  gc_profiling_enabled: enable_gc_profiling?(settings),
82
87
  allocation_counting_enabled: settings.profiling.advanced.allocation_counting_enabled,
83
88
  no_signals_workaround_enabled: no_signals_workaround_enabled,
84
- timeline_enabled: settings.profiling.advanced.experimental_timeline_enabled,
89
+ timeline_enabled: timeline_enabled,
85
90
  )
86
91
  else
87
92
  load_pprof_support
@@ -90,7 +95,12 @@ module Datadog
90
95
  collector = build_profiler_oldstack_collector(settings, recorder, optional_tracer)
91
96
  end
92
97
 
93
- exporter = build_profiler_exporter(settings, recorder, no_signals_workaround_enabled: no_signals_workaround_enabled)
98
+ internal_metadata = {
99
+ no_signals_workaround_enabled: no_signals_workaround_enabled,
100
+ timeline_enabled: timeline_enabled,
101
+ }.freeze
102
+
103
+ exporter = build_profiler_exporter(settings, recorder, internal_metadata: internal_metadata)
94
104
  transport = build_profiler_transport(settings, agent_settings)
95
105
  scheduler = Profiling::Scheduler.new(exporter: exporter, transport: transport)
96
106
 
@@ -101,14 +111,14 @@ module Datadog
101
111
  Profiling::OldRecorder.new([Profiling::Events::StackSample], settings.profiling.advanced.max_events)
102
112
  end
103
113
 
104
- private_class_method def self.build_profiler_exporter(settings, recorder, no_signals_workaround_enabled:)
114
+ private_class_method def self.build_profiler_exporter(settings, recorder, internal_metadata:)
105
115
  code_provenance_collector =
106
116
  (Profiling::Collectors::CodeProvenance.new if settings.profiling.advanced.code_provenance_enabled)
107
117
 
108
118
  Profiling::Exporter.new(
109
119
  pprof_recorder: recorder,
110
120
  code_provenance_collector: code_provenance_collector,
111
- no_signals_workaround_enabled: no_signals_workaround_enabled,
121
+ internal_metadata: internal_metadata,
112
122
  )
113
123
  end
114
124