Module: GraphQL::Tracing

Defined in:
lib/graphql/tracing.rb,
lib/graphql/tracing/active_support_notifications_tracing.rb

Overview

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.

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 { query: GraphQL::Execution::Multiplex }
execute_query { query: GraphQL::Query }
execute_query_lazy { query: GraphQL::Query?, queries: Array<GraphQL::Query>? }
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

Defined Under Namespace

Modules: ActiveSupportNotificationsTracing

Class Method Summary collapse

Class Method Details

.install(tracer) ⇒ void

This method returns an undefined value.

Install a tracer to receive events.

Parameters:

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


46
47
48
49
50
# File 'lib/graphql/tracing.rb', line 46

def install(tracer)
  if !tracers.include?(tracer)
    @tracers << tracer
  end
end

.trace(key, metadata) ⇒ Object

Override this method to do stuff

Parameters:

  • key (String)

    The name of the event in GraphQL internals

  • metadata (Hash)

    Event-related metadata (can be anything)

Returns:

  • (Object)

    Must return the value of the block



39
40
41
# File 'lib/graphql/tracing.rb', line 39

def trace(key, )
  call_tracers(0, key, ) { yield }
end

.tracersObject



56
57
58
# File 'lib/graphql/tracing.rb', line 56

def tracers
  @tracers ||= []
end

.uninstall(tracer) ⇒ Object



52
53
54
# File 'lib/graphql/tracing.rb', line 52

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