Class: Datadog::Core::Configuration::Settings::DSL::Profiling::Advanced

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/core/configuration/settings.rb

Defined Under Namespace

Classes: Endpoint

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#allocation_counting_enabledObject

Can be used to enable/disable the Datadog::Profiling.allocation_count feature.

Requires allocation profiling to be enabled.

Defaults to:

  • false



309
310
311
# File 'lib/datadog/core/configuration/settings.rb', line 309

def allocation_counting_enabled
  @allocation_counting_enabled
end

#code_provenance_enabledObject

Can be used to disable the gathering of names and versions of gems in use by the service, used to power grouping and categorization of stack traces.



283
284
285
# File 'lib/datadog/core/configuration/settings.rb', line 283

def code_provenance_enabled
  @code_provenance_enabled
end

#dir_interruption_workaround_enabledObject

The profiler gathers data by sending SIGPROF unix signals to Ruby application threads.

We've discovered that this can trigger a bug in a number of Ruby APIs in the Dir class, as described in https://bugs.ruby-lang.org/issues/20586 . This was fixed for Ruby 3.4+, and this setting is a no-op for those versions.

otherwise true

Defaults to:

  • DD_PROFILING_DIR_INTERRUPTION_WORKAROUND_ENABLED environment variable as a boolean,



418
419
420
# File 'lib/datadog/core/configuration/settings.rb', line 418

def dir_interruption_workaround_enabled
  @dir_interruption_workaround_enabled
end

#experimental_crash_tracking_enabledObject

DEV-3.0: Remove experimental_crash_tracking_enabled option



453
454
455
# File 'lib/datadog/core/configuration/settings.rb', line 453

def experimental_crash_tracking_enabled
  @experimental_crash_tracking_enabled
end

#experimental_heap_enabledObject

Can be used to enable/disable the collection of heap profiles.

This feature is alpha and disabled by default

Defaults to:

  • DD_PROFILING_EXPERIMENTAL_HEAP_ENABLED environment variable as a boolean, otherwise false



321
322
323
# File 'lib/datadog/core/configuration/settings.rb', line 321

def experimental_heap_enabled
  @experimental_heap_enabled
end

#experimental_heap_sample_rateObject

Can be used to configure the heap sampling rate: a heap sample will be collected for every x allocation samples.

The lower the value, the more accuracy in heap tracking but the bigger the overhead. In particular, a value of 1 will track ALL allocations samples for heap profiles.

The effective heap sampling rate in terms of allocations (not allocation samples) can be calculated via effective_heap_sample_rate = allocation_sample_rate * heap_sample_rate.

Defaults to:

  • DD_PROFILING_EXPERIMENTAL_HEAP_SAMPLE_RATE environment variable, otherwise 10.



351
352
353
# File 'lib/datadog/core/configuration/settings.rb', line 351

def experimental_heap_sample_rate
  @experimental_heap_sample_rate
end

#experimental_heap_size_enabledObject

Can be used to enable/disable the collection of heap size profiles.

This feature is alpha and enabled by default when heap profiling is enabled.

whatever the value of DD_PROFILING_EXPERIMENTAL_HEAP_ENABLED is.

Defaults to:

  • DD_PROFILING_EXPERIMENTAL_HEAP_SIZE_ENABLED environment variable as a boolean, otherwise



335
336
337
# File 'lib/datadog/core/configuration/settings.rb', line 335

def experimental_heap_size_enabled
  @experimental_heap_size_enabled
end

#gc_enabledObject

Can be used to enable/disable garbage collection profiling.

Defaults to:

  • DD_PROFILING_GC_ENABLED environment variable, otherwise true



298
299
300
# File 'lib/datadog/core/configuration/settings.rb', line 298

def gc_enabled
  @gc_enabled
end

#max_framesObject

Controls the maximum number of frames for each thread sampled. Can be tuned to avoid omitted frames in the produced profiles. Increasing this may increase the overhead of profiling.

Defaults to:

  • DD_PROFILING_MAX_FRAMES environment variable, otherwise 400



259
260
261
# File 'lib/datadog/core/configuration/settings.rb', line 259

def max_frames
  @max_frames
end

#no_signals_workaround_enabledObject

The profiler gathers data by sending SIGPROF unix signals to Ruby application threads.

Sending SIGPROF is a common profiling approach, and may cause system calls from native extensions/libraries to be interrupted with a system EINTR error code. Rarely, native extensions or libraries called by them may have missing or incorrect error handling for the EINTR error code.

The "no signals" workaround, when enabled, enables an alternative mode for the profiler where it does not send SIGPROF unix signals. The downside of this approach is that the profiler data will have lower quality.

This workaround is automatically enabled when gems that are known to have issues handling EINTR error codes are detected. If you suspect you may be seeing an issue due to the profiler's use of signals, you can try manually enabling this mode as a fallback. Please also report these issues to us on https://github.com/DataDog/dd-trace-rb/issues/new, so we can work with the gem authors to fix them!

Defaults to:

  • DD_PROFILING_NO_SIGNALS_WORKAROUND_ENABLED environment variable as a boolean, otherwise :auto



399
400
401
# File 'lib/datadog/core/configuration/settings.rb', line 399

def no_signals_workaround_enabled
  @no_signals_workaround_enabled
end

#overhead_target_percentageObject

Configures how much wall-time overhead the profiler targets. The profiler will dynamically adjust the interval between samples it takes so as to try and maintain the property that it spends no longer than this amount of wall-clock time profiling. For example, with the default value of 2%, the profiler will try and cause no more than 1.2 seconds per minute of overhead. Decreasing this value will reduce the accuracy of the data collected. Increasing will impact the application.

We do not recommend tweaking this value.

This value should be a percentage i.e. a number between 0 and 100, not 0 and 1.

Defaults to:

  • DD_PROFILING_OVERHEAD_TARGET_PERCENTAGE as a float, otherwise 2.0



435
436
437
# File 'lib/datadog/core/configuration/settings.rb', line 435

def overhead_target_percentage
  @overhead_target_percentage
end

#preview_gvl_enabledObject

Enables GVL profiling. This will show when threads are waiting for GVL in the timeline view.

This is a preview feature and disabled by default. It requires Ruby 3.2+.

Defaults to:

  • DD_PROFILING_PREVIEW_GVL_ENABLED environment variable as a boolean, otherwise false



469
470
471
# File 'lib/datadog/core/configuration/settings.rb', line 469

def preview_gvl_enabled
  @preview_gvl_enabled
end

#preview_otel_context_enabledObject

Controls if the profiler should attempt to read context from the otel library

Defaults to:

  • false



492
493
494
# File 'lib/datadog/core/configuration/settings.rb', line 492

def preview_otel_context_enabled
  @preview_otel_context_enabled
end

#skip_mysql2_checkObject

Can be used to disable checking which version of libmysqlclient is being used by the mysql2 gem.

This setting is only used when the mysql2 gem is installed.

Defaults to:

  • DD_PROFILING_SKIP_MYSQL2_CHECK environment variable, otherwise false



362
363
364
# File 'lib/datadog/core/configuration/settings.rb', line 362

def skip_mysql2_check
  @skip_mysql2_check
end

#timeline_enabledObject

Controls data collection for the timeline feature.

If you needed to disable this, please tell us why on https://github.com/DataDog/dd-trace-rb/issues/new, so we can fix it!

Defaults to:

  • DD_PROFILING_TIMELINE_ENABLED environment variable as a boolean, otherwise true



374
375
376
# File 'lib/datadog/core/configuration/settings.rb', line 374

def timeline_enabled
  @timeline_enabled
end

#upload_period_secondsObject

Controls how often the profiler reports data, in seconds. Cannot be lower than 60 seconds.

We do not recommend tweaking this value.

Defaults to:

  • DD_PROFILING_UPLOAD_PERIOD environment variable, otherwise 60



446
447
448
# File 'lib/datadog/core/configuration/settings.rb', line 446

def upload_period_seconds
  @upload_period_seconds
end

#waiting_for_gvl_threshold_nsObject

Controls the smallest time period the profiler will report a thread waiting for the GVL.

The default value was set to minimize overhead. Periods smaller than the set value will not be reported (e.g. the thread will be reported as whatever it was doing before it waited for the GVL).

We do not recommend setting this to less than 1ms. Tweaking this value can increase application latency and memory use.

Defaults to:

  • 10_000_000 (10ms)



484
485
486
# File 'lib/datadog/core/configuration/settings.rb', line 484

def waiting_for_gvl_threshold_ns
  @waiting_for_gvl_threshold_ns
end

Instance Method Details

#endpointDatadog::Core::Configuration::Settings::DSL::Profiling::Advanced::Endpoint

Returns a configuration object.



266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/datadog/core/configuration/settings.rb', line 266

settings :endpoint do
  settings :collection do
    # When using profiling together with tracing, this controls if endpoint names
    # are gathered and reported together with profiles.
    #
    # @default `DD_PROFILING_ENDPOINT_COLLECTION_ENABLED` environment variable, otherwise `true`
    # @return [Boolean]
    option :enabled do |o|
      o.env Profiling::Ext::ENV_ENDPOINT_COLLECTION_ENABLED
      o.default true
      o.type :bool
    end
  end
end