class Datadog::Profiling::Pprof::Converter
Base class for converters that convert profiling events to pprof
Constants
- EventGroup
Represents a grouped event 'sample' is an example event object from the group. 'values' is the the summation of the group's sample values
Attributes
builder[R]
Public Class Methods
new(builder, sample_type_mappings)
click to toggle source
# File lib/ddtrace/profiling/pprof/converter.rb, line 18 def initialize(builder, sample_type_mappings) @builder = builder @sample_type_mappings = sample_type_mappings end
sample_value_types()
click to toggle source
Override in child class to define sample types this converter uses when building samples.
# File lib/ddtrace/profiling/pprof/converter.rb, line 14 def self.sample_value_types raise NotImplementedError end
Public Instance Methods
add_events!(events)
click to toggle source
# File lib/ddtrace/profiling/pprof/converter.rb, line 49 def add_events!(events) raise NotImplementedError end
build_sample_values(stack_sample)
click to toggle source
# File lib/ddtrace/profiling/pprof/converter.rb, line 60 def build_sample_values(stack_sample) # Build a value array that matches the length of the sample types # Populate all values with "no value" by default Array.new(@sample_type_mappings.length, Datadog::Ext::Profiling::Pprof::SAMPLE_VALUE_NO_VALUE) end
debug_statistics()
click to toggle source
# File lib/ddtrace/profiling/pprof/converter.rb, line 66 def debug_statistics # Empty; can be used by subclasses to report a string containing debug statistics to be logged end
group_events(events) { |event| ... }
click to toggle source
# File lib/ddtrace/profiling/pprof/converter.rb, line 23 def group_events(events) # Event grouping in format: # [key, EventGroup] event_groups = {} events.each do |event| key = yield(event) values = build_sample_values(event) unless key.nil? if event_groups.key?(key) # Update values for group group_values = event_groups[key].values group_values.each_with_index do |group_value, i| group_values[i] = group_value + values[i] end else # Add new group event_groups[key] = EventGroup.new(event, values) end end end event_groups end
sample_value_index(type)
click to toggle source
# File lib/ddtrace/profiling/pprof/converter.rb, line 53 def sample_value_index(type) index = @sample_type_mappings[type] raise UnknownSampleTypeMappingError, type unless index index end