opentelemetry-instrumentation-graphql 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a43a35c233d2adf52df479778bab10dfb4596bf2e7086782741053a7ee65cc63
|
4
|
+
data.tar.gz: e4dee2b3c3e802bf713678d2968bb196e244d601f757c87f1849d21ce5ee743e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f1c9532656d0626302509ca2d4ffe805eef53d24ae360e3bf3b84bbc8ed6587496f7dcc9677f009fe3ca29bcd97523c8e419cb7fad309f1b64ca6fe582c52c0
|
7
|
+
data.tar.gz: fc763aa2ac3468c0ba901f6a9fee2b0e826f8117a3130a5f9f83e87fa10391f7b80ddfe8837a1e466e4e9312b9bd44033dc66f5a04bac27351b8c77d3ea51de4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-graphql
|
2
2
|
|
3
|
+
### v0.26.0 / 2023-05-17
|
4
|
+
|
5
|
+
* BREAKING CHANGE: GraphQL instrumentation: support new tracing API
|
6
|
+
|
7
|
+
* ADDED: GraphQL instrumentation: support new tracing API
|
8
|
+
|
9
|
+
### v0.25.0 / 2023-04-17
|
10
|
+
|
11
|
+
* BREAKING CHANGE: Drop support for EoL Ruby 2.7
|
12
|
+
|
13
|
+
* ADDED: Drop support for EoL Ruby 2.7
|
14
|
+
|
3
15
|
### v0.24.0 / 2023-03-15
|
4
16
|
|
5
17
|
* BREAKING CHANGE: Add support for GraphQL 2.0.19
|
@@ -12,19 +12,31 @@ module OpenTelemetry
|
|
12
12
|
# The Instrumentation class contains logic to detect and install the GraphQL instrumentation
|
13
13
|
class Instrumentation < OpenTelemetry::Instrumentation::Base
|
14
14
|
compatible do
|
15
|
-
|
16
|
-
|
15
|
+
if config[:legacy_tracing]
|
16
|
+
legacy_tracing_requirement_satisfied?
|
17
|
+
else
|
18
|
+
Gem::Requirement.new('>= 2.0.18', '< 3.0.0').satisfied_by?(gem_version)
|
19
|
+
end
|
17
20
|
end
|
18
21
|
|
19
22
|
install do |config|
|
20
|
-
|
21
|
-
|
23
|
+
if config[:legacy_tracing]
|
24
|
+
require_relative 'tracers/graphql_tracer'
|
25
|
+
install_tracer(config)
|
26
|
+
else
|
27
|
+
require_relative 'tracers/graphql_trace'
|
28
|
+
install_new_tracer(config)
|
29
|
+
end
|
22
30
|
end
|
23
31
|
|
24
32
|
present do
|
25
33
|
defined?(::GraphQL)
|
26
34
|
end
|
27
35
|
|
36
|
+
def legacy_tracing_requirement_satisfied?
|
37
|
+
Gem::Requirement.new('<= 2.0.17').satisfied_by?(gem_version) || Gem::Requirement.new('~> 2.0.19').satisfied_by?(gem_version)
|
38
|
+
end
|
39
|
+
|
28
40
|
## Supported configuration keys for the install config hash:
|
29
41
|
#
|
30
42
|
# The enable_platform_field key expects a boolean value,
|
@@ -49,6 +61,7 @@ module OpenTelemetry
|
|
49
61
|
option :enable_platform_authorized, default: false, validate: :boolean
|
50
62
|
option :enable_platform_resolve_type, default: false, validate: :boolean
|
51
63
|
option :legacy_platform_span_names, default: false, validate: :boolean
|
64
|
+
option :legacy_tracing, default: false, validate: :boolean
|
52
65
|
|
53
66
|
private
|
54
67
|
|
@@ -56,10 +69,6 @@ module OpenTelemetry
|
|
56
69
|
Gem::Version.new(::GraphQL::VERSION)
|
57
70
|
end
|
58
71
|
|
59
|
-
def require_dependencies
|
60
|
-
require_relative 'tracers/graphql_tracer'
|
61
|
-
end
|
62
|
-
|
63
72
|
def install_tracer(config = {})
|
64
73
|
if config[:schemas].empty?
|
65
74
|
::GraphQL::Schema.tracer(Tracers::GraphQLTracer.new)
|
@@ -71,6 +80,18 @@ module OpenTelemetry
|
|
71
80
|
end
|
72
81
|
end
|
73
82
|
end
|
83
|
+
|
84
|
+
def install_new_tracer(config = {})
|
85
|
+
if config[:schemas].empty?
|
86
|
+
::GraphQL::Schema.trace_with(Tracers::GraphQLTrace)
|
87
|
+
else
|
88
|
+
config[:schemas].each do |schema|
|
89
|
+
schema.trace_with(Tracers::GraphQLTrace)
|
90
|
+
rescue StandardError => e
|
91
|
+
OpenTelemetry.logger.error("Unable to patch schema #{schema}: #{e.message}")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
74
95
|
end
|
75
96
|
end
|
76
97
|
end
|
@@ -0,0 +1,197 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
|
+
#
|
5
|
+
# SPDX-License-Identifier: Apache-2.0
|
6
|
+
|
7
|
+
require 'opentelemetry'
|
8
|
+
|
9
|
+
module OpenTelemetry
|
10
|
+
module Instrumentation
|
11
|
+
module GraphQL
|
12
|
+
module Tracers
|
13
|
+
# GraphQLTrace contains the OpenTelemetry tracer implementation compatible with
|
14
|
+
# the new GraphQL tracing API (>= 2.0.18)
|
15
|
+
module GraphQLTrace # rubocop:disable Metrics/ModuleLength
|
16
|
+
def initialize(trace_scalars: false, **_options)
|
17
|
+
@trace_scalars = trace_scalars
|
18
|
+
@platform_field_key_cache = Hash.new { |h, k| h[k] = platform_field_key(k) }
|
19
|
+
@platform_authorized_key_cache = Hash.new { |h, k| h[k] = platform_authorized_key(k) }
|
20
|
+
@platform_resolve_type_key_cache = Hash.new { |h, k| h[k] = platform_resolve_type_key(k) }
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute_multiplex(multiplex:, &block)
|
25
|
+
tracer.in_span('graphql.execute_multiplex', &block)
|
26
|
+
end
|
27
|
+
|
28
|
+
def lex(query_string:, &block)
|
29
|
+
tracer.in_span('graphql.lex', &block)
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse(query_string:, &block)
|
33
|
+
tracer.in_span('graphql.parse', &block)
|
34
|
+
end
|
35
|
+
|
36
|
+
def validate(query:, validate:, &block)
|
37
|
+
tracer.in_span('graphql.validate') do |span|
|
38
|
+
super.tap do |response|
|
39
|
+
errors = response[:errors]&.compact&.map(&:to_h)&.to_json
|
40
|
+
unless errors.nil?
|
41
|
+
span.add_event(
|
42
|
+
'graphql.validation.error',
|
43
|
+
attributes: {
|
44
|
+
'message' => errors
|
45
|
+
}
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def analyze_multiplex(multiplex:, &block)
|
53
|
+
tracer.in_span('graphql.analyze_query', &block)
|
54
|
+
end
|
55
|
+
|
56
|
+
def analyze_query(query:, &block)
|
57
|
+
tracer.in_span('graphql.analyze_multiplex', &block)
|
58
|
+
end
|
59
|
+
|
60
|
+
def execute_query(query:, &block)
|
61
|
+
attributes = {}
|
62
|
+
attributes['graphql.operation.name'] = query.selected_operation_name if query.selected_operation_name
|
63
|
+
attributes['graphql.operation.type'] = query.selected_operation.operation_type
|
64
|
+
attributes['graphql.document'] = query.query_string
|
65
|
+
|
66
|
+
tracer.in_span('graphql.execute_query', attributes: attributes, &block)
|
67
|
+
end
|
68
|
+
|
69
|
+
def execute_query_lazy(query:, &block)
|
70
|
+
tracer.in_span('graphql.execute_query_lazy', &block)
|
71
|
+
end
|
72
|
+
|
73
|
+
def execute_field(field:, query:, ast_node:, arguments:, object:, &block)
|
74
|
+
platform_key = platform_execute_field_key(field)
|
75
|
+
return super unless platform_key
|
76
|
+
|
77
|
+
attributes = {}
|
78
|
+
attributes['graphql.field.parent'] = field.owner&.graphql_name
|
79
|
+
attributes['graphql.field.name'] = field.graphql_name
|
80
|
+
attributes['graphql.field.lazy'] = false
|
81
|
+
|
82
|
+
tracer.in_span(platform_key, attributes: attributes, &block)
|
83
|
+
end
|
84
|
+
|
85
|
+
def execute_field_lazy(field:, query:, ast_node:, arguments:, object:, &block)
|
86
|
+
platform_key = platform_execute_field_key(field)
|
87
|
+
return super unless platform_key
|
88
|
+
|
89
|
+
attributes = {}
|
90
|
+
attributes['graphql.field.parent'] = field.owner&.graphql_name
|
91
|
+
attributes['graphql.field.name'] = field.graphql_name
|
92
|
+
attributes['graphql.field.lazy'] = true
|
93
|
+
|
94
|
+
tracer.in_span(platform_key, attributes: attributes, &block)
|
95
|
+
end
|
96
|
+
|
97
|
+
def authorized(query:, type:, object:, &block)
|
98
|
+
platform_key = @platform_authorized_key_cache[type]
|
99
|
+
return super unless platform_key
|
100
|
+
|
101
|
+
attributes = {}
|
102
|
+
attributes['graphql.type.name'] = type.graphql_name
|
103
|
+
attributes['graphql.lazy'] = false
|
104
|
+
|
105
|
+
tracer.in_span(platform_key, attributes: attributes, &block)
|
106
|
+
end
|
107
|
+
|
108
|
+
def authorized_lazy(query:, type:, object:, &block)
|
109
|
+
platform_key = @platform_authorized_key_cache[type]
|
110
|
+
return super unless platform_key
|
111
|
+
|
112
|
+
attributes = {}
|
113
|
+
attributes['graphql.type.name'] = type.graphql_name
|
114
|
+
attributes['graphql.lazy'] = true
|
115
|
+
|
116
|
+
tracer.in_span(platform_key, attributes: attributes, &block)
|
117
|
+
end
|
118
|
+
|
119
|
+
def resolve_type(query:, type:, object:)
|
120
|
+
platform_key = @platform_resolve_type_key_cache[type]
|
121
|
+
|
122
|
+
attributes = {}
|
123
|
+
attributes['graphql.type.name'] = type.graphql_name
|
124
|
+
attributes['graphql.lazy'] = false
|
125
|
+
|
126
|
+
tracer.in_span(platform_key, attributes: attributes, &block)
|
127
|
+
end
|
128
|
+
|
129
|
+
def resolve_type_lazy(query:, type:, object:)
|
130
|
+
platform_key = @platform_resolve_type_key_cache[type]
|
131
|
+
|
132
|
+
attributes = {}
|
133
|
+
attributes['graphql.type.name'] = type.graphql_name
|
134
|
+
attributes['graphql.lazy'] = true
|
135
|
+
|
136
|
+
tracer.in_span(platform_key, attributes: attributes, &block)
|
137
|
+
end
|
138
|
+
|
139
|
+
private
|
140
|
+
|
141
|
+
def platform_execute_field_key(field:, &block)
|
142
|
+
platform_key = @platform_field_key_cache[field] if trace_field?(field)
|
143
|
+
platform_key if !platform_key.nil? && trace_field
|
144
|
+
end
|
145
|
+
|
146
|
+
def trace_field?(field)
|
147
|
+
return_type = field.type.unwrap
|
148
|
+
|
149
|
+
if return_type.kind.scalar? || return_type.kind.enum?
|
150
|
+
(field.trace.nil? && @trace_scalars) || field.trace
|
151
|
+
else
|
152
|
+
true
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def platform_field_key(field)
|
157
|
+
return unless config[:enable_platform_field]
|
158
|
+
|
159
|
+
if config[:legacy_platform_span_names]
|
160
|
+
field.path
|
161
|
+
else
|
162
|
+
'graphql.execute_field'
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def platform_authorized_key(type)
|
167
|
+
return unless config[:enable_platform_authorized]
|
168
|
+
|
169
|
+
if config[:legacy_platform_span_names]
|
170
|
+
"#{type.graphql_name}.authorized"
|
171
|
+
else
|
172
|
+
'graphql.authorized'
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def platform_resolve_type_key(type)
|
177
|
+
return unless config[:enable_platform_resolve_type]
|
178
|
+
|
179
|
+
if config[:legacy_platform_span_names]
|
180
|
+
"#{type.graphql_name}.resolve_type"
|
181
|
+
else
|
182
|
+
'graphql.resolve_type'
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def tracer
|
187
|
+
GraphQL::Instrumentation.instance.tracer
|
188
|
+
end
|
189
|
+
|
190
|
+
def config
|
191
|
+
GraphQL::Instrumentation.instance.config
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-instrumentation-graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenTelemetry Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.22.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.22.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: appraisal
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,16 +118,16 @@ dependencies:
|
|
118
118
|
name: opentelemetry-test-helpers
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
|
-
- - "
|
121
|
+
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: '0'
|
123
|
+
version: '0.3'
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- - "
|
128
|
+
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: '0'
|
130
|
+
version: '0.3'
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: rake
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,14 +148,14 @@ dependencies:
|
|
148
148
|
requirements:
|
149
149
|
- - "~>"
|
150
150
|
- !ruby/object:Gem::Version
|
151
|
-
version: 1.
|
151
|
+
version: 1.50.2
|
152
152
|
type: :development
|
153
153
|
prerelease: false
|
154
154
|
version_requirements: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
156
|
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version: 1.
|
158
|
+
version: 1.50.2
|
159
159
|
- !ruby/object:Gem::Dependency
|
160
160
|
name: simplecov
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
@@ -227,16 +227,17 @@ files:
|
|
227
227
|
- lib/opentelemetry/instrumentation.rb
|
228
228
|
- lib/opentelemetry/instrumentation/graphql.rb
|
229
229
|
- lib/opentelemetry/instrumentation/graphql/instrumentation.rb
|
230
|
+
- lib/opentelemetry/instrumentation/graphql/tracers/graphql_trace.rb
|
230
231
|
- lib/opentelemetry/instrumentation/graphql/tracers/graphql_tracer.rb
|
231
232
|
- lib/opentelemetry/instrumentation/graphql/version.rb
|
232
233
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
|
233
234
|
licenses:
|
234
235
|
- Apache-2.0
|
235
236
|
metadata:
|
236
|
-
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-graphql/0.
|
237
|
+
changelog_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-graphql/0.26.0/file/CHANGELOG.md
|
237
238
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/instrumentation/graphql
|
238
239
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
|
239
|
-
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-graphql/0.
|
240
|
+
documentation_uri: https://rubydoc.info/gems/opentelemetry-instrumentation-graphql/0.26.0
|
240
241
|
post_install_message:
|
241
242
|
rdoc_options: []
|
242
243
|
require_paths:
|
@@ -245,14 +246,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
245
246
|
requirements:
|
246
247
|
- - ">="
|
247
248
|
- !ruby/object:Gem::Version
|
248
|
-
version:
|
249
|
+
version: '3.0'
|
249
250
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
251
|
requirements:
|
251
252
|
- - ">="
|
252
253
|
- !ruby/object:Gem::Version
|
253
254
|
version: '0'
|
254
255
|
requirements: []
|
255
|
-
rubygems_version: 3.
|
256
|
+
rubygems_version: 3.2.33
|
256
257
|
signing_key:
|
257
258
|
specification_version: 4
|
258
259
|
summary: GraphQL instrumentation for the OpenTelemetry framework
|