Class: Datadog::Profiling::Pprof::Converter
- Inherits:
 - 
      Object
      
        
- Object
 - Datadog::Profiling::Pprof::Converter
 
 
- Defined in:
 - lib/ddtrace/profiling/pprof/converter.rb
 
Overview
Base class for converters that convert profiling events to pprof
Direct Known Subclasses
Defined Under Namespace
Classes: EventGroup, UnknownSampleTypeMappingError
Instance Attribute Summary collapse
- 
  
    
      #builder  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute builder.
 
Class Method Summary collapse
- 
  
    
      .sample_value_types  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Override in child class to define sample types this converter uses when building samples.
 
Instance Method Summary collapse
- #add_events!(events) ⇒ Object
 - #build_event_values(event) ⇒ Object
 - #debug_statistics ⇒ Object
 - #group_events(events) ⇒ Object
 - 
  
    
      #initialize(builder, sample_type_mappings)  ⇒ Converter 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Converter.
 - #sample_value_index(type) ⇒ Object
 
Constructor Details
#initialize(builder, sample_type_mappings) ⇒ Converter
Returns a new instance of Converter.
      18 19 20 21  | 
    
      # File 'lib/ddtrace/profiling/pprof/converter.rb', line 18 def initialize(builder, sample_type_mappings) @builder = builder @sample_type_mappings = sample_type_mappings end  | 
  
Instance Attribute Details
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
      9 10 11  | 
    
      # File 'lib/ddtrace/profiling/pprof/converter.rb', line 9 def builder @builder end  | 
  
Class Method Details
.sample_value_types ⇒ Object
Override in child class to define sample types this converter uses when building samples.
      14 15 16  | 
    
      # File 'lib/ddtrace/profiling/pprof/converter.rb', line 14 def self.sample_value_types raise NotImplementedError end  | 
  
Instance Method Details
#add_events!(events) ⇒ Object
      48 49 50  | 
    
      # File 'lib/ddtrace/profiling/pprof/converter.rb', line 48 def add_events!(events) raise NotImplementedError end  | 
  
#build_event_values(event) ⇒ Object
      59 60 61 62 63  | 
    
      # File 'lib/ddtrace/profiling/pprof/converter.rb', line 59 def build_event_values(event) # 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 ⇒ Object
      65 66 67  | 
    
      # File 'lib/ddtrace/profiling/pprof/converter.rb', line 65 def debug_statistics # Empty; can be used by subclasses to report a string containing debug statistics to be logged end  | 
  
#group_events(events) ⇒ Object
      23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46  | 
    
      # File 'lib/ddtrace/profiling/pprof/converter.rb', line 23 def group_events(events) # Event grouping in format: # [key, EventGroup] event_groups = {} # Aggregate each event into a group # with identical properties, but different values. events.each do |event| key = yield(event) values = build_event_values(event) unless key.nil? if event_groups.key?(key) # Update existing group from event update_group(event_groups[key], event, values) else # Add new group event_groups[key] = new_group(event, values) end end end event_groups end  | 
  
#sample_value_index(type) ⇒ Object
      52 53 54 55 56 57  | 
    
      # File 'lib/ddtrace/profiling/pprof/converter.rb', line 52 def sample_value_index(type) index = @sample_type_mappings[type] raise UnknownSampleTypeMappingError, type unless index index end  |