Module: GraphQL::Tracing::ScoutTrace

Includes:
PlatformTrace
Defined in:
lib/graphql/tracing/scout_trace.rb

Overview

A tracer for sending GraphQL-Ruby times to Scout

Examples:

Adding this tracer to your schema

class MySchema < GraphQL::Schema
  trace_with GraphQL::Tracing::ScoutTrace
end

Constant Summary collapse

INSTRUMENT_OPTS =
{ scope: true }

Instance Method Summary collapse

Methods included from PlatformTrace

#platform_authorized_lazy, #platform_execute_field_lazy, #platform_resolve_type_lazy

Instance Method Details

#initialize(set_transaction_name: false, **_rest) ⇒ Object

Parameters:

  • set_transaction_name (Boolean) (defaults to: false)

    If true, the GraphQL operation name will be used as the transaction name. This is not advised if you run more than one query per HTTP request, for example, with graphql-client or multiplexing. It can also be specified per-query with context[:set_scout_transaction_name].



21
22
23
24
25
# File 'lib/graphql/tracing/scout_trace.rb', line 21

def initialize(set_transaction_name: false, **_rest)
  self.class.include(ScoutApm::Tracer)
  @set_transaction_name = set_transaction_name
  super
end

#platform_authorized(platform_key, &block) ⇒ Object Also known as: platform_resolve_type



64
65
66
# File 'lib/graphql/tracing/scout_trace.rb', line 64

def platform_authorized(platform_key, &block)
  self.class.instrument("GraphQL", platform_key, INSTRUMENT_OPTS, &block)
end

#platform_authorized_key(type) ⇒ Object



74
75
76
# File 'lib/graphql/tracing/scout_trace.rb', line 74

def platform_authorized_key(type)
  "#{type.graphql_name}.authorized"
end

#platform_execute_field(platform_key, &block) ⇒ Object

rubocop:enable Development/NoEvalCop



60
61
62
# File 'lib/graphql/tracing/scout_trace.rb', line 60

def platform_execute_field(platform_key, &block)
  self.class.instrument("GraphQL", platform_key, INSTRUMENT_OPTS, &block)
end

#platform_field_key(field) ⇒ Object



70
71
72
# File 'lib/graphql/tracing/scout_trace.rb', line 70

def platform_field_key(field)
  field.path
end

#platform_resolve_type_key(type) ⇒ Object



78
79
80
# File 'lib/graphql/tracing/scout_trace.rb', line 78

def platform_resolve_type_key(type)
  "#{type.graphql_name}.resolve_type"
end