instana 1.13.0 → 1.193.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of instana might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/gemfiles/libraries.gemfile +2 -0
- data/lib/instana/config.rb +1 -0
- data/lib/instana/instrumentation/graphql.rb +77 -0
- data/lib/instana/tracing/span.rb +2 -2
- data/lib/instana/version.rb +1 -1
- data/test/instrumentation/graphql_test.rb +116 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fa2d34630db364163860954f67e65c38f76b6534e34b857cacaa2bc5fb06697
|
4
|
+
data.tar.gz: d458b50ec707675d06c5891b92af7e2efe1bb7c60d19713721e439a158060be9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6ac5ae188ddd4217d2f378690b88080c7cb3dd92375eac1feae16cd37dd9607b9332dce11c2df1408a7f0b4a24a5f79b6f3a26057a539ccb2a8c37963f900b7
|
7
|
+
data.tar.gz: e27dd436e1d4e0f7fdfdec35c1dcb252e32dce84d3eb8a06143d03bbb49dd839179da8d056c46080167cc9b9d940474a8678b341667c723006b1a9528a8c4b53
|
data/gemfiles/libraries.gemfile
CHANGED
data/lib/instana/config.rb
CHANGED
@@ -48,6 +48,7 @@ module Instana
|
|
48
48
|
@config[:dalli] = { :enabled => true }
|
49
49
|
@config[:excon] = { :enabled => true }
|
50
50
|
@config[:grpc] = { :enabled => true }
|
51
|
+
@config[:graphql] = { :enabled => true }
|
51
52
|
@config[:nethttp] = { :enabled => true }
|
52
53
|
@config[:redis] = { :enabled => true }
|
53
54
|
@config[:'resque-client'] = { :enabled => true }
|
@@ -0,0 +1,77 @@
|
|
1
|
+
if defined?(GraphQL::Schema) && defined?(GraphQL::Tracing::PlatformTracing) && ::Instana.config[:graphql][:enabled]
|
2
|
+
module Instana
|
3
|
+
class GraphqlTracing < GraphQL::Tracing::PlatformTracing
|
4
|
+
self.platform_keys = {
|
5
|
+
'lex' => 'lex.graphql',
|
6
|
+
'parse' => 'parse.graphql',
|
7
|
+
'validate' => 'validate.graphql',
|
8
|
+
'analyze_query' => 'analyze.graphql',
|
9
|
+
'analyze_multiplex' => 'analyze.graphql',
|
10
|
+
'execute_multiplex' => 'execute.graphql',
|
11
|
+
'execute_query' => 'execute.graphql',
|
12
|
+
'execute_query_lazy' => 'execute.graphql',
|
13
|
+
}
|
14
|
+
|
15
|
+
def platform_trace(platform_key, key, data)
|
16
|
+
return yield unless key == 'execute_query'
|
17
|
+
operation = data[:query].selected_operation
|
18
|
+
|
19
|
+
arguments = []
|
20
|
+
fields = []
|
21
|
+
|
22
|
+
operation.selections.each do |field|
|
23
|
+
arguments.concat(walk_fields(field, :arguments))
|
24
|
+
fields.concat(walk_fields(field, :selections))
|
25
|
+
end
|
26
|
+
|
27
|
+
payload = {
|
28
|
+
operationName: data[:query].operation_name || 'anonymous',
|
29
|
+
operationType: operation.operation_type,
|
30
|
+
arguments: grouped_fields(arguments),
|
31
|
+
fields: grouped_fields(fields),
|
32
|
+
}
|
33
|
+
|
34
|
+
begin
|
35
|
+
::Instana.tracer.log_entry(:'graphql.server')
|
36
|
+
yield
|
37
|
+
rescue Exception => e
|
38
|
+
::Instana.tracer.log_error(e)
|
39
|
+
raise e
|
40
|
+
ensure
|
41
|
+
::Instana.tracer.log_exit(:'graphql.server', {graphql: payload})
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def platform_field_key(type, field)
|
46
|
+
"#{type.graphql_name}.#{field.graphql_name}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def platform_authorized_key(type)
|
50
|
+
"#{type.graphql_name}.authorized.graphql"
|
51
|
+
end
|
52
|
+
|
53
|
+
def platform_resolve_type_key(type)
|
54
|
+
"#{type.graphql_name}.resolve_type.graphql"
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def walk_fields(parent, method)
|
60
|
+
return [] unless parent.respond_to?(method)
|
61
|
+
|
62
|
+
parent.send(method).map do |field|
|
63
|
+
[{object: parent.name, field: field.name}] + walk_fields(field, method)
|
64
|
+
end.flatten
|
65
|
+
end
|
66
|
+
|
67
|
+
def grouped_fields(fields)
|
68
|
+
fields
|
69
|
+
.group_by { |p| p[:object] }
|
70
|
+
.map { |name, p| [name, p.map { |f| f[:field] }] }
|
71
|
+
.to_h
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
::GraphQL::Schema.use(::Instana::GraphqlTracing)
|
77
|
+
end
|
data/lib/instana/tracing/span.rb
CHANGED
@@ -3,8 +3,8 @@ module Instana
|
|
3
3
|
REGISTERED_SPANS = [ :actioncontroller, :actionview, :activerecord, :excon,
|
4
4
|
:memcache, :'net-http', :rack, :render, :'rpc-client',
|
5
5
|
:'rpc-server', :'sidekiq-client', :'sidekiq-worker',
|
6
|
-
:redis, :'resque-client', :'resque-worker' ].freeze
|
7
|
-
ENTRY_SPANS = [ :rack, :'resque-worker', :'rpc-server', :'sidekiq-worker' ].freeze
|
6
|
+
:redis, :'resque-client', :'resque-worker', :'graphql.server' ].freeze
|
7
|
+
ENTRY_SPANS = [ :rack, :'resque-worker', :'rpc-server', :'sidekiq-worker', :'graphql.server' ].freeze
|
8
8
|
EXIT_SPANS = [ :activerecord, :excon, :'net-http', :'resque-client',
|
9
9
|
:'rpc-client', :'sidekiq-client', :redis ].freeze
|
10
10
|
HTTP_SPANS = [ :rack, :excon, :'net-http' ].freeze
|
data/lib/instana/version.rb
CHANGED
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class GraphqlTest < Minitest::Test
|
4
|
+
class TaskType < GraphQL::Schema::Object
|
5
|
+
field :id, ID, null: false
|
6
|
+
field :action, String, null: false
|
7
|
+
end
|
8
|
+
|
9
|
+
class NewTaskType < GraphQL::Schema::Mutation
|
10
|
+
argument :action, String, required: true
|
11
|
+
field :task, TaskType, null: true
|
12
|
+
|
13
|
+
def resolve(action:)
|
14
|
+
{
|
15
|
+
task: OpenStruct.new(id: '0', action: action)
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class QueryType < GraphQL::Schema::Object
|
21
|
+
field :tasks, TaskType.connection_type, null: false
|
22
|
+
|
23
|
+
def tasks()
|
24
|
+
[
|
25
|
+
OpenStruct.new(id: '0', action: 'Sample')
|
26
|
+
]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class MutationType < GraphQL::Schema::Object
|
31
|
+
field :create_task, mutation: NewTaskType
|
32
|
+
end
|
33
|
+
|
34
|
+
class Schema < GraphQL::Schema
|
35
|
+
query QueryType
|
36
|
+
mutation MutationType
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_it_works
|
40
|
+
assert defined?(GraphQL)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_config_defaults
|
44
|
+
assert ::Instana.config[:graphql].is_a?(Hash)
|
45
|
+
assert ::Instana.config[:graphql].key?(:enabled)
|
46
|
+
assert_equal true, ::Instana.config[:graphql][:enabled]
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_query
|
50
|
+
clear_all!
|
51
|
+
|
52
|
+
query = "query Sample {
|
53
|
+
tasks(after: \"\", first: 10) {
|
54
|
+
nodes {
|
55
|
+
action
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}"
|
59
|
+
|
60
|
+
expected_data = {
|
61
|
+
:operationName => "Sample",
|
62
|
+
:operationType => "query",
|
63
|
+
:arguments => { "tasks" => ["after", "first"] },
|
64
|
+
:fields => { "tasks" => ["nodes"], "nodes" => ["action"] }
|
65
|
+
}
|
66
|
+
expected_results = {
|
67
|
+
"data" => {
|
68
|
+
"tasks" => {
|
69
|
+
"nodes" => [{ "action" => "Sample" }]
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
results = Instana.tracer.start_or_continue_trace('graphql-test') { Schema.execute(query) }
|
75
|
+
query_span, root_span = *Instana.processor.queued_spans
|
76
|
+
|
77
|
+
assert_equal expected_results, results.to_h
|
78
|
+
assert_equal :sdk, root_span[:n]
|
79
|
+
assert_equal :'graphql.server', query_span[:n]
|
80
|
+
assert_equal expected_data, query_span[:data][:graphql]
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_mutation
|
84
|
+
clear_all!
|
85
|
+
|
86
|
+
query = "mutation Sample {
|
87
|
+
createTask(action: \"Sample\") {
|
88
|
+
task {
|
89
|
+
action
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}"
|
93
|
+
|
94
|
+
expected_data = {
|
95
|
+
:operationName => "Sample",
|
96
|
+
:operationType => "mutation",
|
97
|
+
:arguments => { "createTask" => ["action"] },
|
98
|
+
:fields => { "createTask" => ["task"], "task" => ["action"] }
|
99
|
+
}
|
100
|
+
expected_results = {
|
101
|
+
"data" => {
|
102
|
+
"createTask" => {
|
103
|
+
"task" => { "action" => "Sample" }
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
results = Instana.tracer.start_or_continue_trace('graphql-test') { Schema.execute(query) }
|
109
|
+
query_span, root_span = *Instana.processor.queued_spans
|
110
|
+
|
111
|
+
assert_equal expected_results, results.to_h
|
112
|
+
assert_equal :sdk, root_span[:n]
|
113
|
+
assert_equal :'graphql.server', query_span[:n]
|
114
|
+
assert_equal expected_data, query_span[:data][:graphql]
|
115
|
+
end
|
116
|
+
end
|
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.
|
4
|
+
version: 1.193.0
|
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: 2021-01-
|
11
|
+
date: 2021-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -231,6 +231,7 @@ files:
|
|
231
231
|
- lib/instana/instrumentation.rb
|
232
232
|
- lib/instana/instrumentation/dalli.rb
|
233
233
|
- lib/instana/instrumentation/excon.rb
|
234
|
+
- lib/instana/instrumentation/graphql.rb
|
234
235
|
- lib/instana/instrumentation/grpc.rb
|
235
236
|
- lib/instana/instrumentation/net-http.rb
|
236
237
|
- lib/instana/instrumentation/rack.rb
|
@@ -275,6 +276,7 @@ files:
|
|
275
276
|
- test/instana_test.rb
|
276
277
|
- test/instrumentation/dalli_test.rb
|
277
278
|
- test/instrumentation/excon_test.rb
|
279
|
+
- test/instrumentation/graphql_test.rb
|
278
280
|
- test/instrumentation/grpc_test.rb
|
279
281
|
- test/instrumentation/net-http_test.rb
|
280
282
|
- test/instrumentation/redis_test.rb
|
@@ -338,6 +340,7 @@ test_files:
|
|
338
340
|
- test/models/block.rb
|
339
341
|
- test/models/block6.rb
|
340
342
|
- test/secrets_test.rb
|
343
|
+
- test/instrumentation/graphql_test.rb
|
341
344
|
- test/instrumentation/sidekiq-client_test.rb
|
342
345
|
- test/instrumentation/resque_test.rb
|
343
346
|
- test/instrumentation/sidekiq-worker_test.rb
|