class Datadog::Profiling::Collectors::ThreadContext

Methods prefixed with native are implemented in ‘collectors_thread_context.c`
Almost all of this class is implemented as native code.
The stack collection itself is handled using the Datadog::Profiling::Collectors::Stack.
Collectors::CpuAndWallTimeWorker.
Triggering of this component (e.g. watching for the above “events”) is implemented by
* VM object allocation events
* VM garbage collection events
* periodic timer for cpu-time and wall-time
Used to trigger sampling of threads, based on external “events”, such as:

def initialize(

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

def inspect

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

def reset_after_fork

def reset_after_fork
  self.class._native_reset_after_fork(self)
end

def safely_extract_context_key_from(tracer)

def safely_extract_context_key_from(tracer)
  provider = tracer && tracer.respond_to?(:provider) && tracer.provider
  return unless provider
  context = provider.instance_variable_get(:@context)
  context && context.instance_variable_get(:@key)
end