instana 1.209.7 → 1.209.8
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 +4 -4
- data/lib/instana/instrumentation/graphql.rb +14 -1
- data/lib/instana/version.rb +1 -1
- data/test/instrumentation/graphql_test.rb +155 -26
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1461b6f3821df0472c4d486c1256069909ed6c833e8016e70e06d14130124704
|
4
|
+
data.tar.gz: 4f6d244e93cd9bdf2b1e3aa895d8824df136123f46a829a02059d4f82c3d0a75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7533b3a686d6f432cfad515c4625b687c4d14d593acc15bde81bae500d1c170582ebaea43a4527807d68f1e70397ede59e0659c3898f1ecaba5c8311095b0110
|
7
|
+
data.tar.gz: 55e6433ff8f6eb247ef63d1b9d8321e4c82aefd94c8838347bdae07fbac6d3d01903a60db6df32b36430bc351b375f5a8e1630a1d34adf15053dcb28152d71de
|
@@ -63,7 +63,20 @@ module Instana
|
|
63
63
|
return [] unless parent.respond_to?(method)
|
64
64
|
|
65
65
|
parent.send(method).map do |field|
|
66
|
-
|
66
|
+
# Certain types like GraphQL::Language::Nodes::InlineFragment
|
67
|
+
# have no "name" instance variable defined,
|
68
|
+
# in such case we use the class's name
|
69
|
+
parent_name = if parent.instance_variable_defined?(:@name)
|
70
|
+
parent.name
|
71
|
+
else
|
72
|
+
parent.class.name.split('::').last
|
73
|
+
end
|
74
|
+
field_name = if field.instance_variable_defined?(:@name)
|
75
|
+
field.name
|
76
|
+
else
|
77
|
+
field.class.name.split('::').last
|
78
|
+
end
|
79
|
+
[{object: parent_name, field: field_name}] + walk_fields(field, method)
|
67
80
|
end.flatten
|
68
81
|
end
|
69
82
|
|
data/lib/instana/version.rb
CHANGED
@@ -8,84 +8,213 @@ class GraphqlTest < Minitest::Test
|
|
8
8
|
field :id, ID, null: false
|
9
9
|
field :action, String, null: false
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
|
+
class JobType < GraphQL::Schema::Object
|
13
|
+
field :id, ID, null: false
|
14
|
+
field :name, String, null: false
|
15
|
+
field :description, String, null: false
|
16
|
+
end
|
17
|
+
|
18
|
+
class TaskJobUnion < GraphQL::Schema::Union
|
19
|
+
description "A union type for Task and Job"
|
20
|
+
possible_types TaskType, JobType
|
21
|
+
|
22
|
+
def self.resolve_type(object, _context)
|
23
|
+
if !object.action.nil?
|
24
|
+
TaskType
|
25
|
+
elsif !object.description?
|
26
|
+
JobType
|
27
|
+
else
|
28
|
+
raise("Unexpected object: #{object}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
12
33
|
class NewTaskType < GraphQL::Schema::Mutation
|
13
34
|
argument :action, String, required: true
|
14
35
|
field :task, TaskType, null: true
|
15
|
-
|
36
|
+
|
16
37
|
def resolve(action:)
|
17
38
|
{
|
18
39
|
task: OpenStruct.new(id: '0', action: action)
|
19
40
|
}
|
20
41
|
end
|
21
42
|
end
|
22
|
-
|
43
|
+
|
23
44
|
class QueryType < GraphQL::Schema::Object
|
24
45
|
field :tasks, TaskType.connection_type, null: false
|
25
|
-
|
46
|
+
field :jobs, JobType.connection_type, null: false
|
47
|
+
field :tasksorjobs, TaskJobUnion.connection_type, null: false
|
48
|
+
|
26
49
|
def tasks()
|
27
50
|
[
|
28
|
-
OpenStruct.new(id: '0', action: 'Sample')
|
51
|
+
OpenStruct.new(id: '0', action: 'Sample 00'),
|
52
|
+
OpenStruct.new(id: '1', action: 'Sample 01'),
|
53
|
+
OpenStruct.new(id: '2', action: 'Sample 02'),
|
54
|
+
OpenStruct.new(id: '3', action: 'Sample 03'),
|
55
|
+
OpenStruct.new(id: '4', action: 'Sample 04')
|
56
|
+
]
|
57
|
+
end
|
58
|
+
|
59
|
+
def jobs()
|
60
|
+
[
|
61
|
+
OpenStruct.new(id: '0', name: 'Name 00', description: 'Desc 00'),
|
62
|
+
OpenStruct.new(id: '1', name: 'Name 01', description: 'Desc 01'),
|
63
|
+
OpenStruct.new(id: '2', name: 'Name 02', description: 'Desc 02'),
|
64
|
+
OpenStruct.new(id: '3', name: 'Name 03', description: 'Desc 03'),
|
65
|
+
OpenStruct.new(id: '4', name: 'Name 04', description: 'Desc 04')
|
66
|
+
]
|
67
|
+
end
|
68
|
+
|
69
|
+
def tasksorjobs()
|
70
|
+
[
|
71
|
+
OpenStruct.new(id: '0', action: 'Task 00'),
|
72
|
+
OpenStruct.new(id: '0', name: 'Job 00', description: 'Job Desc 00')
|
29
73
|
]
|
30
74
|
end
|
31
75
|
end
|
32
|
-
|
76
|
+
|
33
77
|
class MutationType < GraphQL::Schema::Object
|
34
78
|
field :create_task, mutation: NewTaskType
|
35
79
|
end
|
36
|
-
|
80
|
+
|
37
81
|
class Schema < GraphQL::Schema
|
38
82
|
query QueryType
|
39
83
|
mutation MutationType
|
40
84
|
end
|
41
|
-
|
85
|
+
|
42
86
|
def test_it_works
|
43
87
|
assert defined?(GraphQL)
|
44
88
|
end
|
45
|
-
|
46
|
-
def test_config_defaults
|
89
|
+
|
90
|
+
def test_config_defaults
|
47
91
|
assert ::Instana.config[:graphql].is_a?(Hash)
|
48
92
|
assert ::Instana.config[:graphql].key?(:enabled)
|
49
93
|
assert_equal true, ::Instana.config[:graphql][:enabled]
|
50
94
|
end
|
51
|
-
|
95
|
+
|
52
96
|
def test_query
|
53
97
|
clear_all!
|
54
|
-
|
55
|
-
query = "query
|
56
|
-
tasks(after: \"\", first:
|
98
|
+
|
99
|
+
query = "query FirstTwoTaskSamples {
|
100
|
+
tasks(after: \"\", first: 2) {
|
57
101
|
nodes {
|
58
102
|
action
|
59
103
|
}
|
60
104
|
}
|
61
105
|
}"
|
62
|
-
|
106
|
+
|
63
107
|
expected_data = {
|
64
|
-
:operationName => "
|
108
|
+
:operationName => "FirstTwoTaskSamples",
|
65
109
|
:operationType => "query",
|
66
110
|
:arguments => { "tasks" => ["after", "first"] },
|
67
111
|
:fields => { "tasks" => ["nodes"], "nodes" => ["action"] }
|
68
112
|
}
|
69
113
|
expected_results = {
|
70
114
|
"data" => {
|
71
|
-
"tasks" => {
|
72
|
-
"nodes" => [{ "action" => "Sample"
|
115
|
+
"tasks" => {
|
116
|
+
"nodes" => [{"action" => "Sample 00"}, {"action" => "Sample 01"}]
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
results = Instana.tracer.start_or_continue_trace('graphql-test') { Schema.execute(query) }
|
122
|
+
query_span, root_span = *Instana.processor.queued_spans
|
123
|
+
|
124
|
+
assert_equal expected_results, results.to_h
|
125
|
+
assert_equal :sdk, root_span[:n]
|
126
|
+
assert_equal :'graphql.server', query_span[:n]
|
127
|
+
assert_equal expected_data, query_span[:data][:graphql]
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_query_with_fragment
|
131
|
+
clear_all!
|
132
|
+
|
133
|
+
query = "
|
134
|
+
fragment actionDetails on Task {
|
135
|
+
action
|
136
|
+
}
|
137
|
+
|
138
|
+
query SampleWithFragment {
|
139
|
+
tasks {
|
140
|
+
nodes {
|
141
|
+
... actionDetails
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}"
|
145
|
+
|
146
|
+
expected_data = {
|
147
|
+
:operationName => "SampleWithFragment",
|
148
|
+
:operationType => "query",
|
149
|
+
:arguments => {},
|
150
|
+
:fields => { "tasks" => ["nodes"], "nodes" => ["actionDetails"] }
|
151
|
+
}
|
152
|
+
expected_results = {
|
153
|
+
"data" => {
|
154
|
+
"tasks" => {
|
155
|
+
"nodes" => [{"action" => "Sample 00"}, {"action" => "Sample 01"},
|
156
|
+
{"action" => "Sample 02"}, {"action" => "Sample 03"},
|
157
|
+
{"action" => "Sample 04"}]
|
73
158
|
}
|
74
159
|
}
|
75
160
|
}
|
76
|
-
|
161
|
+
|
77
162
|
results = Instana.tracer.start_or_continue_trace('graphql-test') { Schema.execute(query) }
|
78
163
|
query_span, root_span = *Instana.processor.queued_spans
|
79
|
-
|
164
|
+
|
80
165
|
assert_equal expected_results, results.to_h
|
81
166
|
assert_equal :sdk, root_span[:n]
|
82
167
|
assert_equal :'graphql.server', query_span[:n]
|
83
168
|
assert_equal expected_data, query_span[:data][:graphql]
|
84
169
|
end
|
85
|
-
|
170
|
+
|
171
|
+
def test_query_union_with_fragment
|
172
|
+
clear_all!
|
173
|
+
|
174
|
+
query = "
|
175
|
+
query QueryUnionWithFragment {
|
176
|
+
tasksorjobs {
|
177
|
+
nodes {
|
178
|
+
... on Task {
|
179
|
+
action
|
180
|
+
}
|
181
|
+
... on Job {
|
182
|
+
name
|
183
|
+
description
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}"
|
188
|
+
|
189
|
+
expected_data = {
|
190
|
+
:operationName => "QueryUnionWithFragment",
|
191
|
+
:operationType => "query",
|
192
|
+
:arguments => {},
|
193
|
+
:fields => { "tasksorjobs" => ["nodes"],
|
194
|
+
"nodes" => ["InlineFragment", "InlineFragment"],
|
195
|
+
"InlineFragment" => %w[action name description]}
|
196
|
+
}
|
197
|
+
expected_results = {
|
198
|
+
"data" => {
|
199
|
+
"tasksorjobs" => {
|
200
|
+
"nodes" => [{"action" => "Task 00"},
|
201
|
+
{"name" => "Job 00", "description" => "Job Desc 00"}]
|
202
|
+
}
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
results = Instana.tracer.start_or_continue_trace('graphql-test') { Schema.execute(query) }
|
207
|
+
query_span, root_span = *Instana.processor.queued_spans
|
208
|
+
|
209
|
+
assert_equal expected_results, results.to_h
|
210
|
+
assert_equal :sdk, root_span[:n]
|
211
|
+
assert_equal :'graphql.server', query_span[:n]
|
212
|
+
assert_equal expected_data, query_span[:data][:graphql]
|
213
|
+
end
|
214
|
+
|
86
215
|
def test_mutation
|
87
216
|
clear_all!
|
88
|
-
|
217
|
+
|
89
218
|
query = "mutation Sample {
|
90
219
|
createTask(action: \"Sample\") {
|
91
220
|
task {
|
@@ -93,7 +222,7 @@ class GraphqlTest < Minitest::Test
|
|
93
222
|
}
|
94
223
|
}
|
95
224
|
}"
|
96
|
-
|
225
|
+
|
97
226
|
expected_data = {
|
98
227
|
:operationName => "Sample",
|
99
228
|
:operationType => "mutation",
|
@@ -102,15 +231,15 @@ class GraphqlTest < Minitest::Test
|
|
102
231
|
}
|
103
232
|
expected_results = {
|
104
233
|
"data" => {
|
105
|
-
"createTask" => {
|
234
|
+
"createTask" => {
|
106
235
|
"task" => { "action" => "Sample" }
|
107
236
|
}
|
108
237
|
}
|
109
238
|
}
|
110
|
-
|
239
|
+
|
111
240
|
results = Instana.tracer.start_or_continue_trace('graphql-test') { Schema.execute(query) }
|
112
241
|
query_span, root_span = *Instana.processor.queued_spans
|
113
|
-
|
242
|
+
|
114
243
|
assert_equal expected_results, results.to_h
|
115
244
|
assert_equal :sdk, root_span[:n]
|
116
245
|
assert_equal :'graphql.server', query_span[:n]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.209.
|
4
|
+
version: 1.209.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Giacomo Lombardo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|