Module: Datadog::Profiling

Defined in:
lib/datadog/profiling.rb,
lib/datadog/profiling/ext.rb,
lib/datadog/profiling/event.rb,
lib/datadog/profiling/flush.rb,
lib/datadog/profiling/buffer.rb,
lib/datadog/profiling/exporter.rb,
lib/datadog/profiling/profiler.rb,
lib/datadog/profiling/component.rb,
lib/datadog/profiling/scheduler.rb,
lib/datadog/profiling/tasks/exec.rb,
lib/datadog/profiling/tasks/help.rb,
lib/datadog/profiling/ext/forking.rb,
lib/datadog/profiling/tag_builder.rb,
lib/datadog/profiling/tasks/setup.rb,
lib/datadog/profiling/events/stack.rb,
lib/datadog/profiling/old_recorder.rb,
lib/datadog/profiling/pprof/builder.rb,
lib/datadog/profiling/pprof/payload.rb,
lib/datadog/profiling/http_transport.rb,
lib/datadog/profiling/pprof/template.rb,
lib/datadog/profiling/stack_recorder.rb,
lib/datadog/profiling/pprof/converter.rb,
lib/datadog/profiling/collectors/stack.rb,
lib/datadog/profiling/encoding/profile.rb,
lib/datadog/profiling/native_extension.rb,
lib/datadog/profiling/pprof/message_set.rb,
lib/datadog/profiling/backtrace_location.rb,
lib/datadog/profiling/pprof/stack_sample.rb,
lib/datadog/profiling/pprof/string_table.rb,
lib/datadog/profiling/collectors/old_stack.rb,
lib/datadog/profiling/trace_identifiers/helper.rb,
lib/datadog/profiling/collectors/thread_context.rb,
lib/datadog/profiling/trace_identifiers/ddtrace.rb,
lib/datadog/profiling/collectors/code_provenance.rb,
lib/datadog/profiling/collectors/idle_sampling_helper.rb,
lib/datadog/profiling/collectors/dynamic_sampling_rate.rb,
lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb,
ext/ddtrace_profiling_native_extension/profiling.c,
ext/ddtrace_profiling_loader/ddtrace_profiling_loader.c,
ext/ddtrace_profiling_native_extension/native_extension_helpers.rb

Overview

Datadog Continuous Profiler implementation: docs.datadoghq.com/profiler/

Defined Under Namespace

Modules: Collectors, Component, Encoding, Events, Ext, Loader, NativeExtension, NativeExtensionHelpers, Pprof, TagBuilder, Tasks, TraceIdentifiers Classes: BacktraceLocation, Buffer, Event, EventGroup, Exporter, Flush, HttpTransport, OldRecorder, Profiler, Scheduler, StackRecorder

Class Method Summary collapse

Class Method Details

.allocation_countObject

rubocop:disable Lint/DuplicateMethods, Lint/NestedMethodDefinition (On purpose!)



63
64
65
66
67
# File 'lib/datadog/profiling.rb', line 63

def self.allocation_count
  # This no-op implementation is used when profiling failed to load.
  # It gets replaced inside #replace_noop_allocation_count.
  nil
end

.start_if_enabledBoolean

Starts the profiler, if the profiler is supported by in this runtime environment and if the profiler has been enabled in configuration.

Returns:

  • (Boolean)

    ‘true` if the profiler has successfully started, otherwise `false`.



32
33
34
35
36
37
38
39
40
# File 'lib/datadog/profiling.rb', line 32

def self.start_if_enabled
  # If the profiler was not previously touched, getting the profiler instance triggers start as a side-effect
  # otherwise we get nil
  profiler = Datadog.send(:components).profiler
  # ...but we still try to start it BECAUSE if the process forks, the profiler will exist but may
  # not yet have been started in the fork
  profiler.start if profiler
  !!profiler
end

.supported?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/datadog/profiling.rb', line 11

def self.supported?
  unsupported_reason.nil?
end

.unsupported_reasonObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/datadog/profiling.rb', line 15

def self.unsupported_reason
  # NOTE: Only the first matching reason is returned, so try to keep a nice order on reasons -- e.g. tell users
  # first that they can't use this on JRuby before telling them that they are missing protobuf

  native_library_compilation_skipped? ||
    native_library_failed_to_load? ||
    protobuf_gem_unavailable? ||
    protobuf_version_unsupported? ||
    protobuf_failed_to_load?
end