Module: GraphQL::Tracing::AppOpticsTrace
- Includes:
- PlatformTrace
- Defined in:
- lib/graphql/tracing/appoptics_trace.rb
Overview
This class uses the AppopticsAPM SDK from the appoptics_apm gem to create
traces for GraphQL.
There are 4 configurations available. They can be set in the
appoptics_apm config file or in code. Please see:
https://docs.appoptics.com/kb/apm_tracing/ruby/configure
AppOpticsAPM::Config[:graphql][:enabled] = true|false
AppOpticsAPM::Config[:graphql][:transaction_name] = true|false
AppOpticsAPM::Config[:graphql][:sanitize_query] = true|false
AppOpticsAPM::Config[:graphql][:remove_comments] = true|false
Constant Summary
collapse
- PREP_KEYS =
These GraphQL events will show up as 'graphql.prep' spans
['lex', 'parse', 'validate', 'analyze_query', 'analyze_multiplex'].freeze
- EXEC_KEYS =
These GraphQL events will show up as 'graphql.execute' spans
['execute_multiplex', 'execute_query', 'execute_query_lazy'].freeze
Class Method Summary
collapse
-
.version ⇒ Object
During auto-instrumentation this version of AppOpticsTracing is compared with the version provided in the appoptics_apm gem, so that the newer version of the class can be used.
Instance Method Summary
collapse
#initialize, #platform_authorized_lazy, #platform_execute_field_lazy, #platform_resolve_type_lazy
Class Method Details
.version ⇒ Object
During auto-instrumentation this version of AppOpticsTracing is compared
with the version provided in the appoptics_apm gem, so that the newer
version of the class can be used
29
30
31
|
# File 'lib/graphql/tracing/appoptics_trace.rb', line 29
def self.version
Gem::Version.new('1.0.0')
end
|
Instance Method Details
#authorized(**data) ⇒ Object
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/graphql/tracing/appoptics_trace.rb', line 90
def authorized(**data)
return super if !defined?(AppOpticsAPM) || gql_config[:enabled] == false
layer = @platform_key_cache[AppOpticsTrace].platform_authorized_key_cache[data[:type]]
kvs = metadata(data, layer)
::AppOpticsAPM::SDK.trace(layer, kvs) do
kvs.clear super
end
end
|
#authorized_lazy(**data) ⇒ Object
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/graphql/tracing/appoptics_trace.rb', line 101
def authorized_lazy(**data)
return super if !defined?(AppOpticsAPM) || gql_config[:enabled] == false
layer = @platform_key_cache[AppOpticsTrace].platform_authorized_key_cache[data[:type]]
kvs = metadata(data, layer)
::AppOpticsAPM::SDK.trace(layer, kvs) do
kvs.clear super
end
end
|
#execute_field(query:, field:, ast_node:, arguments:, object:) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/graphql/tracing/appoptics_trace.rb', line 60
def execute_field(query:, field:, ast_node:, arguments:, object:)
return_type = field.type.unwrap
trace_field = if return_type.kind.scalar? || return_type.kind.enum?
(field.trace.nil? && @trace_scalars) || field.trace
else
true
end
platform_key = if trace_field
@platform_key_cache[AppOpticsTrace].platform_field_key_cache[field]
else
nil
end
if platform_key && trace_field
return super if !defined?(AppOpticsAPM) || gql_config[:enabled] == false
layer = platform_key
kvs = metadata({query: query, field: field, ast_node: ast_node, arguments: arguments, object: object}, layer)
::AppOpticsAPM::SDK.trace(layer, kvs) do
kvs.clear super
end
else
super
end
end
|
#execute_field_lazy(query:, field:, ast_node:, arguments:, object:) ⇒ Object
86
87
88
|
# File 'lib/graphql/tracing/appoptics_trace.rb', line 86
def execute_field_lazy(query:, field:, ast_node:, arguments:, object:)
execute_field(query: query, field: field, ast_node: ast_node, arguments: arguments, object: object)
end
|
141
142
143
|
# File 'lib/graphql/tracing/appoptics_trace.rb', line 141
def platform_authorized_key(type)
"graphql.authorized.#{type.graphql_name}"
end
|
137
138
139
|
# File 'lib/graphql/tracing/appoptics_trace.rb', line 137
def platform_field_key(field)
"graphql.#{field.owner.graphql_name}.#{field.graphql_name}"
end
|
145
146
147
|
# File 'lib/graphql/tracing/appoptics_trace.rb', line 145
def platform_resolve_type_key(type)
"graphql.resolve_type.#{type.graphql_name}"
end
|
#resolve_type(**data) ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/graphql/tracing/appoptics_trace.rb', line 112
def resolve_type(**data)
return super if !defined?(AppOpticsAPM) || gql_config[:enabled] == false
layer = @platform_key_cache[AppOpticsTrace].platform_resolve_type_key_cache[data[:type]]
kvs = metadata(data, layer)
::AppOpticsAPM::SDK.trace(layer, kvs) do
kvs.clear super
end
end
|
#resolve_type_lazy(**data) ⇒ Object
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/graphql/tracing/appoptics_trace.rb', line 124
def resolve_type_lazy(**data)
return super if !defined?(AppOpticsAPM) || gql_config[:enabled] == false
layer = @platform_key_cache[AppOpticsTrace].platform_resolve_type_key_cache[data[:type]]
kvs = metadata(data, layer)
::AppOpticsAPM::SDK.trace(layer, kvs) do
kvs.clear super
end
end
|