Class: GraphQL::Tracing::DataDogTracing

Inherits:
PlatformTracing show all
Defined in:
lib/graphql/tracing/data_dog_tracing.rb

Instance Method Summary collapse

Methods inherited from PlatformTracing

#initialize, #instrument, #trace, #trace_field, use

Constructor Details

This class inherits a constructor from GraphQL::Tracing::PlatformTracing

Instance Method Details

#platform_field_key(type, field) ⇒ Object


40
41
42
# File 'lib/graphql/tracing/data_dog_tracing.rb', line 40

def platform_field_key(type, field)
  "#{type.name}.#{field.name}"
end

#platform_trace(platform_key, key, data) ⇒ Object


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/graphql/tracing/data_dog_tracing.rb', line 17

def platform_trace(platform_key, key, data)
  service = options.fetch(:service, 'ruby-graphql')

  pin = Datadog::Pin.get_from(self)
  unless pin
    pin = Datadog::Pin.new(service)
    pin.onto(self)
  end

  pin.tracer.trace(platform_key, service: pin.service) do |span|
    if key == 'execute_multiplex'
      span.resource = data[:multiplex].queries.map(&:selected_operation_name).join(', ')
    end

    if key == 'execute_query'
      span.set_tag(:selected_operation_name, data[:query].selected_operation_name)
      span.set_tag(:selected_operation_type, data[:query].selected_operation.operation_type)
      span.set_tag(:query_string, data[:query].query_string)
    end
    yield
  end
end