module GraphQL::Tracing
Library entry point for performance metric reporting.
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 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 83 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
@deprecated See {Schema#tracer} or use `context: { tracers: […] }`
# File lib/graphql/tracing.rb, line 96 def tracers @tracers ||= [] end
@deprecated See {Schema#tracer} or use `context: { tracers: […] }`
# File lib/graphql/tracing.rb, line 91 def uninstall(tracer) @tracers.delete(tracer) end