ddtrace 1.17.0 → 1.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +85 -2
  3. data/ext/ddtrace_profiling_native_extension/clock_id_from_pthread.c +3 -0
  4. data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +67 -52
  5. data/ext/ddtrace_profiling_native_extension/collectors_dynamic_sampling_rate.c +22 -14
  6. data/ext/ddtrace_profiling_native_extension/collectors_dynamic_sampling_rate.h +4 -0
  7. data/ext/ddtrace_profiling_native_extension/collectors_gc_profiling_helper.c +156 -0
  8. data/ext/ddtrace_profiling_native_extension/collectors_gc_profiling_helper.h +5 -0
  9. data/ext/ddtrace_profiling_native_extension/collectors_stack.c +43 -102
  10. data/ext/ddtrace_profiling_native_extension/collectors_stack.h +10 -3
  11. data/ext/ddtrace_profiling_native_extension/collectors_thread_context.c +167 -125
  12. data/ext/ddtrace_profiling_native_extension/collectors_thread_context.h +2 -1
  13. data/ext/ddtrace_profiling_native_extension/extconf.rb +44 -10
  14. data/ext/ddtrace_profiling_native_extension/heap_recorder.c +970 -0
  15. data/ext/ddtrace_profiling_native_extension/heap_recorder.h +155 -0
  16. data/ext/ddtrace_profiling_native_extension/helpers.h +2 -0
  17. data/ext/ddtrace_profiling_native_extension/http_transport.c +5 -2
  18. data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.c +20 -0
  19. data/ext/ddtrace_profiling_native_extension/libdatadog_helpers.h +11 -0
  20. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +83 -18
  21. data/ext/ddtrace_profiling_native_extension/private_vm_api_access.h +6 -0
  22. data/ext/ddtrace_profiling_native_extension/profiling.c +2 -0
  23. data/ext/ddtrace_profiling_native_extension/ruby_helpers.c +147 -0
  24. data/ext/ddtrace_profiling_native_extension/ruby_helpers.h +28 -0
  25. data/ext/ddtrace_profiling_native_extension/stack_recorder.c +330 -13
  26. data/ext/ddtrace_profiling_native_extension/stack_recorder.h +3 -0
  27. data/lib/datadog/appsec/component.rb +4 -1
  28. data/lib/datadog/appsec/configuration/settings.rb +4 -0
  29. data/lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb +2 -0
  30. data/lib/datadog/appsec/processor/rule_loader.rb +60 -0
  31. data/lib/datadog/appsec/remote.rb +12 -9
  32. data/lib/datadog/core/configuration/settings.rb +139 -22
  33. data/lib/datadog/core/configuration.rb +4 -0
  34. data/lib/datadog/core/remote/worker.rb +1 -0
  35. data/lib/datadog/core/telemetry/collector.rb +10 -0
  36. data/lib/datadog/core/telemetry/event.rb +2 -1
  37. data/lib/datadog/core/telemetry/ext.rb +3 -0
  38. data/lib/datadog/core/telemetry/v1/app_event.rb +8 -1
  39. data/lib/datadog/core/telemetry/v1/install_signature.rb +38 -0
  40. data/lib/datadog/core/workers/async.rb +1 -0
  41. data/lib/datadog/kit/enable_core_dumps.rb +5 -6
  42. data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +7 -11
  43. data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -0
  44. data/lib/datadog/profiling/component.rb +210 -18
  45. data/lib/datadog/profiling/scheduler.rb +4 -6
  46. data/lib/datadog/profiling/stack_recorder.rb +13 -2
  47. data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +4 -0
  48. data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +2 -1
  49. data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +5 -0
  50. data/lib/datadog/tracing/contrib/pg/instrumentation.rb +24 -0
  51. data/lib/datadog/tracing/contrib/rails/auto_instrument_railtie.rb +0 -2
  52. data/lib/datadog/tracing/workers.rb +1 -0
  53. data/lib/ddtrace/version.rb +1 -1
  54. metadata +11 -6
@@ -81,10 +81,7 @@ end
81
81
 
82
82
  # Because we can't control what compiler versions our customers use, shipping with -Werror by default is a no-go.
83
83
  # But we can enable it in CI, so that we quickly spot any new warnings that just got introduced.
84
- #
85
- # @ivoanjo TODO: 3.3.0-preview releases are causing issues in CI because `have_header('vm_core.h')` below triggers warnings;
86
- # I've chosen to disable `-Werror` for this Ruby version for now, and we can revisit this on a later 3.3 release.
87
- add_compiler_flag '-Werror' if ENV['DDTRACE_CI'] == 'true' && !RUBY_DESCRIPTION.include?('3.3.0preview')
84
+ add_compiler_flag '-Werror' if ENV['DDTRACE_CI'] == 'true'
88
85
 
89
86
  # Older gcc releases may not default to C99 and we need to ask for this. This is also used:
90
87
  # * by upstream Ruby -- search for gnu99 in the codebase
@@ -102,9 +99,6 @@ add_compiler_flag '-Wno-declaration-after-statement'
102
99
  # cause a segfault later. Let's ensure that never happens.
103
100
  add_compiler_flag '-Werror-implicit-function-declaration'
104
101
 
105
- # Warn on unused parameters to functions. Use `DDTRACE_UNUSED` to mark things as known-to-not-be-used.
106
- add_compiler_flag '-Wunused-parameter'
107
-
108
102
  # The native extension is not intended to expose any symbols/functions for other native libraries to use;
109
103
  # the sole exception being `Init_ddtrace_profiling_native_extension` which needs to be visible for Ruby to call it when
110
104
  # it `dlopen`s the library.
@@ -120,6 +114,11 @@ add_compiler_flag '-Wold-style-definition'
120
114
  add_compiler_flag '-Wall'
121
115
  add_compiler_flag '-Wextra'
122
116
 
117
+ if ENV['DDTRACE_DEBUG']
118
+ CONFIG['optflags'] = '-O0'
119
+ CONFIG['debugflags'] = '-ggdb3'
120
+ end
121
+
123
122
  if RUBY_PLATFORM.include?('linux')
124
123
  # Supposedly, the correct way to do this is
125
124
  # ```
@@ -131,6 +130,12 @@ if RUBY_PLATFORM.include?('linux')
131
130
  $defs << '-DHAVE_PTHREAD_GETCPUCLOCKID'
132
131
  end
133
132
 
133
+ # On older Rubies, rb_postponed_job_preregister/rb_postponed_job_trigger did not exist
134
+ $defs << '-DNO_POSTPONED_TRIGGER' if RUBY_VERSION < '3.3'
135
+
136
+ # On older Rubies, M:N threads were not available
137
+ $defs << '-DNO_MN_THREADS_AVAILABLE' if RUBY_VERSION < '3.3'
138
+
134
139
  # On older Rubies, we did not need to include the ractor header (this was built into the MJIT header)
135
140
  $defs << '-DNO_RACTOR_HEADER_INCLUDE' if RUBY_VERSION < '3.3'
136
141
 
@@ -152,12 +157,18 @@ $defs << '-DNO_PRIMITIVE_POP' if RUBY_VERSION < '3.2'
152
157
  # On older Rubies, there was no tid member in the internal thread structure
153
158
  $defs << '-DNO_THREAD_TID' if RUBY_VERSION < '3.1'
154
159
 
160
+ # On older Rubies, there was no jit_return member on the rb_control_frame_t struct
161
+ $defs << '-DNO_JIT_RETURN' if RUBY_VERSION < '3.1'
162
+
155
163
  # On older Rubies, we need to use a backported version of this function. See private_vm_api_access.h for details.
156
164
  $defs << '-DUSE_BACKPORTED_RB_PROFILE_FRAME_METHOD_NAME' if RUBY_VERSION < '3'
157
165
 
158
166
  # On older Rubies, there are no Ractors
159
167
  $defs << '-DNO_RACTORS' if RUBY_VERSION < '3'
160
168
 
169
+ # On older Rubies, rb_imemo_name did not exist
170
+ $defs << '-DNO_IMEMO_NAME' if RUBY_VERSION < '3'
171
+
161
172
  # On older Rubies, objects would not move
162
173
  $defs << '-DNO_T_MOVED' if RUBY_VERSION < '2.7'
163
174
 
@@ -181,6 +192,14 @@ if RUBY_VERSION < '2.4'
181
192
  $defs << '-DUSE_LEGACY_RB_VM_FRAME_METHOD_ENTRY'
182
193
  end
183
194
 
195
+ # On older Rubies, rb_gc_force_recycle allowed to free objects in a way that
196
+ # would be invisible to free tracepoints, finalizers and without cleaning
197
+ # obj_to_id_tbl mappings.
198
+ $defs << '-DHAVE_WORKING_RB_GC_FORCE_RECYCLE' if RUBY_VERSION < '3.1'
199
+
200
+ # On older Rubies, there was no RUBY_SEEN_OBJ_ID flag
201
+ $defs << '-DNO_SEEN_OBJ_ID_FLAG' if RUBY_VERSION < '2.7'
202
+
184
203
  # If we got here, libdatadog is available and loaded
185
204
  ENV['PKG_CONFIG_PATH'] = "#{ENV['PKG_CONFIG_PATH']}:#{Libdatadog.pkgconfig_folder}"
186
205
  Logging.message("[ddtrace] PKG_CONFIG_PATH set to #{ENV['PKG_CONFIG_PATH'].inspect}\n")
@@ -238,6 +257,10 @@ if Datadog::Profiling::NativeExtensionHelpers::CAN_USE_MJIT_HEADER
238
257
  # NOTE: This needs to come after all changes to $defs
239
258
  create_header
240
259
 
260
+ # Warn on unused parameters to functions. Use `DDTRACE_UNUSED` to mark things as known-to-not-be-used.
261
+ # See the comment on the same flag below for why this is done last.
262
+ add_compiler_flag '-Wunused-parameter'
263
+
241
264
  create_makefile EXTENSION_NAME
242
265
  else
243
266
  # The MJIT header was introduced on 2.6 and removed on 3.3; for other Rubies we rely on
@@ -253,9 +276,20 @@ else
253
276
  Debase::RubyCoreSource
254
277
  .create_makefile_with_core(
255
278
  proc do
256
- have_header('vm_core.h') &&
257
- have_header('iseq.h') &&
258
- (RUBY_VERSION < '3.3' || have_header('ractor_core.h'))
279
+ headers_available =
280
+ have_header('vm_core.h') &&
281
+ have_header('iseq.h') &&
282
+ (RUBY_VERSION < '3.3' || have_header('ractor_core.h'))
283
+
284
+ if headers_available
285
+ # Warn on unused parameters to functions. Use `DDTRACE_UNUSED` to mark things as known-to-not-be-used.
286
+ # This is added as late as possible because in some Rubies we support (e.g. 3.3), adding this flag before
287
+ # checking if internal VM headers are available causes those checks to fail because of this warning (and not
288
+ # because the headers are not available.)
289
+ add_compiler_flag '-Wunused-parameter'
290
+ end
291
+
292
+ headers_available
259
293
  end,
260
294
  EXTENSION_NAME,
261
295
  )