Module: GraphQL::Tracing::AppsignalTrace

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

Overview

Instrumentation for reporting GraphQL-Ruby times to Appsignal.

Examples:

Installing the tracer

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

Instance Method Summary collapse

Methods included from PlatformTrace

#platform_authorized_lazy, #platform_execute_field_lazy, #platform_resolve_type_lazy

Instance Method Details

#initialize(set_action_name: false, **rest) ⇒ Object

Parameters:

  • set_action_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_appsignal_action_name].



19
20
21
22
# File 'lib/graphql/tracing/appsignal_trace.rb', line 19

def initialize(set_action_name: false, **rest)
  @set_action_name = set_action_name
  super
end

#platform_authorized(platform_key) ⇒ Object



60
61
62
63
64
# File 'lib/graphql/tracing/appsignal_trace.rb', line 60

def platform_authorized(platform_key)
  Appsignal.instrument(platform_key) do
    yield
  end
end

#platform_authorized_key(type) ⇒ Object



76
77
78
# File 'lib/graphql/tracing/appsignal_trace.rb', line 76

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

#platform_execute_field(platform_key) ⇒ Object



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

def platform_execute_field(platform_key)
  Appsignal.instrument(platform_key) do
    yield
  end
end

#platform_field_key(field) ⇒ Object



72
73
74
# File 'lib/graphql/tracing/appsignal_trace.rb', line 72

def platform_field_key(field)
  "#{field.owner.graphql_name}.#{field.graphql_name}.graphql"
end

#platform_resolve_type(platform_key) ⇒ Object



66
67
68
69
70
# File 'lib/graphql/tracing/appsignal_trace.rb', line 66

def platform_resolve_type(platform_key)
  Appsignal.instrument(platform_key) do
    yield
  end
end

#platform_resolve_type_key(type) ⇒ Object



80
81
82
# File 'lib/graphql/tracing/appsignal_trace.rb', line 80

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