module NewRelic::Agent::InfiniteTracing::Transformer

Constants

KLASS_TO_ARG

Public Instance Methods

transform(span_event) click to toggle source
# File lib/infinite_tracing/transformer.rb, line 11
def transform span_event
  intrinsics, user_attributes, agent_attributes = span_event
  {
    "trace_id" => intrinsics[NewRelic::Agent::SpanEventPrimitive::TRACE_ID_KEY],
    "intrinsics" => hash_to_attributes(intrinsics),
    "user_attributes" => hash_to_attributes(user_attributes),
    "agent_attributes" => hash_to_attributes(agent_attributes)
  }
end

Private Instance Methods

hash_to_attributes(values) click to toggle source
# File lib/infinite_tracing/transformer.rb, line 41
def hash_to_attributes values
  values.map do |key, value|
    begin
      [key, AttributeValue.new(safe_param_name(value) => value)]
    rescue => e
      puts e.inspect
      puts [key, value].inspect
      nil
    end
  end.to_h
end
safe_param_name(value) click to toggle source
# File lib/infinite_tracing/transformer.rb, line 37
def safe_param_name value
  KLASS_TO_ARG[value.class] || raise("Unhandled class #{value.class.name}")
end