Class: Datadog::Profiling::Collectors::ThreadContext

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/profiling/collectors/thread_context.rb,
ext/ddtrace_profiling_native_extension/collectors_thread_context.c

Overview

Used to trigger sampling of threads, based on external “events”, such as:

  • periodic timer for cpu-time and wall-time

  • VM garbage collection events

  • VM object allocation events

Triggering of this component (e.g. watching for the above “events”) is implemented by Collectors::CpuAndWallTimeWorker. The stack collection itself is handled using the Datadog::Profiling::Collectors::Stack. Almost all of this class is implemented as native code.

Methods prefixed with native are implemented in ‘collectors_thread_context.c`

Defined Under Namespace

Modules: Testing

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recorder:, max_frames:, tracer:, endpoint_collection_enabled:) ⇒ ThreadContext

Returns a new instance of ThreadContext.



17
18
19
20
# File 'lib/datadog/profiling/collectors/thread_context.rb', line 17

def initialize(recorder:, max_frames:, tracer:, endpoint_collection_enabled:)
  tracer_context_key = safely_extract_context_key_from(tracer)
  self.class._native_initialize(self, recorder, max_frames, tracer_context_key, endpoint_collection_enabled)
end

Class Method Details

._native_initializeObject



145
146
147
148
149
150
151
152
# File 'ext/ddtrace_profiling_native_extension/collectors_thread_context.c', line 145

static VALUE _native_initialize(
  VALUE self,
  VALUE collector_instance,
  VALUE recorder_instance,
  VALUE max_frames,
  VALUE tracer_context_key,
  VALUE endpoint_collection_enabled
);

._native_inspectObject



177
# File 'ext/ddtrace_profiling_native_extension/collectors_thread_context.c', line 177

static VALUE _native_inspect(VALUE self, VALUE collector_instance);

._native_reset_after_forkObject



190
# File 'ext/ddtrace_profiling_native_extension/collectors_thread_context.c', line 190

static VALUE _native_reset_after_fork(DDTRACE_UNUSED VALUE self, VALUE collector_instance);

Instance Method Details

#inspectObject



22
23
24
25
26
27
# File 'lib/datadog/profiling/collectors/thread_context.rb', line 22

def inspect
  # Compose Ruby's default inspect with our custom inspect for the native parts
  result = super()
  result[-1] = "#{self.class._native_inspect(self)}>"
  result
end

#reset_after_forkObject



29
30
31
# File 'lib/datadog/profiling/collectors/thread_context.rb', line 29

def reset_after_fork
  self.class._native_reset_after_fork(self)
end