module GraphQL::Tracing

Library entry point for performance metric reporting.

{ActiveSupportNotificationsTracing} is imported by default when `ActiveSupport::Notifications` is found.

You can remove it with `GraphQL::Tracing.uninstall(GraphQL::Tracing::ActiveSupportNotificationsTracing)`.

Warning: Installing/uninstalling tracers is not thread-safe. Do it during application boot only.

@example Sending custom events

GraphQL::Tracing.trace("my_custom_event", { ... }) do
  # do stuff ...
end

@example Adding a tracer to a schema

MySchema = GraphQL::Schema.define do
  tracer MyTracer # <= responds to .trace(key, data, &block)
end

@example Adding a tracer to a query

MySchema.execute(query_str, context: { backtrace: true })

Events:

Key | Metadata —-|——— lex | `{ query_string: String }` parse | `{ query_string: String }` validate | `{ query: GraphQL::Query, validate: Boolean }` analyze_multiplex | `{ multiplex: GraphQL::Execution::Multiplex }` analyze_query | `{ query: GraphQL::Query }` execute_multiplex | `{ multiplex: GraphQL::Execution::Multiplex }` execute_query | `{ query: GraphQL::Query }` execute_query_lazy | `{ query: GraphQL::Query?, multiplex: GraphQL::Execution::Multiplex? }` execute_field | `{ context: GraphQL::Query::Context::FieldResolutionContext }` execute_field_lazy | `{ context: GraphQL::Query::Context::FieldResolutionContext }`

Public Class Methods

install(tracer) click to toggle source

Install a tracer to receive events. @param tracer [<#trace(key, metadata)>] @return [void] @deprecated See {Schema#tracer} or use `context: { tracers: […] }`

# File lib/graphql/tracing.rb, line 82
def install(tracer)
  warn("GraphQL::Tracing.install is deprecated, add it to the schema with `tracer(my_tracer)` instead.")
  if !tracers.include?(tracer)
    @tracers << tracer
  end
end
tracers() click to toggle source

@deprecated See {Schema#tracer} or use `context: { tracers: […] }`

# File lib/graphql/tracing.rb, line 95
def tracers
  @tracers ||= []
end
uninstall(tracer) click to toggle source

@deprecated See {Schema#tracer} or use `context: { tracers: […] }`

# File lib/graphql/tracing.rb, line 90
def uninstall(tracer)
  @tracers.delete(tracer)
end