module Datadog::Contrib::ActiveModelSerializers::Event::ClassMethods

Class methods for ActiveModelSerializers events. Note, they share the same process method and before_trace method.

Public Instance Methods

configuration() click to toggle source
# File lib/ddtrace/contrib/active_model_serializers/event.rb, line 27
def configuration
  Datadog.configuration[:active_model_serializers]
end
process(span, event, _id, payload) click to toggle source
# File lib/ddtrace/contrib/active_model_serializers/event.rb, line 31
def process(span, event, _id, payload)
  span.service = configuration[:service_name]

  # Set analytics sample rate
  if Contrib::Analytics.enabled?(configuration[:analytics_enabled])
    Contrib::Analytics.set_sample_rate(span, configuration[:analytics_sample_rate])
  end

  # Measure service stats
  Contrib::Analytics.set_measured(span)

  # Set the resource name and serializer name
  res = resource(payload[:serializer])
  span.resource = res
  span.set_tag(Ext::TAG_SERIALIZER, res)

  span.span_type = Datadog::Ext::HTTP::TEMPLATE

  # Will be nil in 0.9
  span.set_tag(Ext::TAG_ADAPTER, payload[:adapter].class) unless payload[:adapter].nil?
end
span_options() click to toggle source
# File lib/ddtrace/contrib/active_model_serializers/event.rb, line 19
def span_options
  { service: configuration[:service_name] }
end
tracer() click to toggle source
# File lib/ddtrace/contrib/active_model_serializers/event.rb, line 23
def tracer
  -> { configuration[:tracer] }
end

Private Instance Methods

resource(serializer) click to toggle source
# File lib/ddtrace/contrib/active_model_serializers/event.rb, line 55
def resource(serializer)
  # Depending on the version of ActiveModelSerializers
  # serializer will be a string or an object.
  if serializer.respond_to?(:name)
    serializer.name
  else
    serializer
  end
end