module ApolloStudioTracing

Trace events are nested and fire in this order for a simple single-field query like `{ foo }`:

<execute_multiplex>

<lex></lex>
<parse></parse>
<validate></validate>
<analyze_multiplex>
  <analyze_query></analyze_query>
</analyze_multiplex>

<execute_query>
  <execute_field></execute_field>
</execute_query>

<execute_query_lazy>

  # `execute_field_lazy` fires *only* when the field is lazy
  # (https://graphql-ruby.org/schema/lazy_execution.html)
  # so if it fires we should overwrite the ending times recorded
  # in `execute_field` to capture the total execution time.

  <execute_field_lazy></execute_field_lazy>

</execute_query_lazy>

# `execute_query_lazy` *always* fires, so it's a
# safe place to capture ending times of the full query.

</execute_multiplex>

Constants

DEBUG_KEY
Error
KEY
Location
Node
Report
ReportHeader
Trace
TracesAndStats
VERSION

Attributes

logger[RW]

Public Instance Methods

flush() click to toggle source
# File lib/apollo-studio-tracing.rb, line 30
def flush
  tracers.each(&:flush_trace_channel)
end
shutdown() click to toggle source
# File lib/apollo-studio-tracing.rb, line 34
def shutdown
  tracers.each(&:shutdown_trace_channel)
end
use(schema, enabled: true, **options) click to toggle source
# File lib/apollo-studio-tracing.rb, line 19
def use(schema, enabled: true, **options)
  return unless enabled

  tracer = ApolloStudioTracing::Tracer.new(**options)
  # TODO: Shutdown tracers when reloading code in Rails
  # (although it's unlikely you'll have Apollo Tracing enabled in development)
  tracers << tracer
  schema.tracer(tracer)
  tracer.start_trace_channel
end

Private Instance Methods

tracers() click to toggle source
# File lib/apollo-studio-tracing.rb, line 42
def tracers
  @tracers ||= []
end