Module: GraphQL::Tracing

Defined in:
lib/graphql/tracing.rb,
lib/graphql/tracing/scout_tracing.rb,
lib/graphql/tracing/data_dog_tracing.rb,
lib/graphql/tracing/platform_tracing.rb,
lib/graphql/tracing/skylight_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.

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

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 }

Examples:

Sending custom events

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

Adding a tracer to a schema

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

Adding a tracer to a query

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

Defined Under Namespace

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

Class Method Summary collapse

Class Method Details

.install(tracer) ⇒ void

Deprecated.

See Schema.tracer or use context: { tracers: [...] }

This method returns an undefined value.

Install a tracer to receive events.

Parameters:

  • tracer (<#trace(key, metadata)>)


83
84
85
86
87
88
# 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

.tracersObject

Deprecated.

See Schema.tracer or use context: { tracers: [...] }



96
97
98
# File 'lib/graphql/tracing.rb', line 96

def tracers
  @tracers ||= []
end

.uninstall(tracer) ⇒ Object

Deprecated.

See Schema.tracer or use context: { tracers: [...] }



91
92
93
# File 'lib/graphql/tracing.rb', line 91

def uninstall(tracer)
  @tracers.delete(tracer)
end