Module: GraphQL::Tracing

Defined in:
lib/graphql/tracing.rb,
lib/graphql/tracing/scout_tracing.rb,
lib/graphql/tracing/statsd_tracing.rb,
lib/graphql/tracing/data_dog_tracing.rb,
lib/graphql/tracing/platform_tracing.rb,
lib/graphql/tracing/skylight_tracing.rb,
lib/graphql/tracing/appoptics_tracing.rb,
lib/graphql/tracing/appsignal_tracing.rb,
lib/graphql/tracing/new_relic_tracing.rb,
lib/graphql/tracing/prometheus_tracing.rb,
lib/graphql/tracing/active_support_notifications_tracing.rb,
lib/graphql/tracing/prometheus_tracing/graphql_collector.rb

Overview

Library entry point for performance metric reporting.

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 { owner: Class, field: GraphQL::Schema::Field, query: GraphQL::Query, path: Array<String, Integer>, ast_node: GraphQL::Language::Nodes::Field}
execute_field_lazy { owner: Class, field: GraphQL::Schema::Field, query: GraphQL::Query, path: Array<String, Integer>, ast_node: GraphQL::Language::Nodes::Field}
authorized { context: GraphQL::Query::Context, type: Class, object: Object, path: Array<String, Integer> }
authorized_lazy { context: GraphQL::Query::Context, type: Class, object: Object, path: Array<String, Integer> }
resolve_type { context: GraphQL::Query::Context, type: Class, object: Object, path: Array<String, Integer> }
resolve_type_lazy { context: GraphQL::Query::Context, type: Class, object: Object, path: Array<String, Integer> }

Note that execute_field and execute_field_lazy receive different data in different settings:

  • When using Execution::Interpreter, they receive {field:, path:, query:}
  • Otherwise, they receive {context: ...}

Examples:

Sending custom events

query.trace("my_custom_event", { ... }) do
  # do stuff ...
end

Adding a tracer to a schema

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

Adding a tracer to a single query

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

Defined Under Namespace

Modules: ActiveSupportNotificationsTracing, NullTracer, Traceable Classes: AppOpticsTracing, AppsignalTracing, DataDogTracing, NewRelicTracing, PlatformTracing, PrometheusTracing, ScoutTracing, SkylightTracing, StatsdTracing