instana 1.13.0 → 1.192.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemfiles/libraries.gemfile +2 -0
- data/lib/instana/config.rb +11 -0
- data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +7 -1
- data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +7 -1
- data/lib/instana/frameworks/instrumentation/postgresql_adapter.rb +23 -5
- data/lib/instana/instrumentation/graphql.rb +77 -0
- data/lib/instana/tracing/span.rb +14 -10
- data/lib/instana/version.rb +1 -1
- data/test/frameworks/rack_test.rb +2 -10
- data/test/frameworks/rails/activerecord_test.rb +80 -28
- data/test/instrumentation/excon_test.rb +0 -2
- data/test/instrumentation/graphql_test.rb +116 -0
- data/test/instrumentation/redis_test.rb +10 -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: 424f7ce1ff02d56a5498df4f3f861231c30f5032cf02e8604e008155c389f4b5
|
4
|
+
data.tar.gz: aac1bf703a70d5c7039fbae031846d513a5d3d9d2c5d00630308eacd8b862095
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9470f7a3f6e1d7198a99d8017556689b0eaffb3bc22677064cbb1f5552f80c8814d481dc842b8a082e5a9c5a6cb86b0f46d95cbbc8055d56c7b2588277bbdaa
|
7
|
+
data.tar.gz: c9e83f799f6b343e6dd98840fcdc48175cc52d9a876c9421e053909bf0dcbfaaf384669b449ce53edf3bd0478ece21484c01c27fd24b6247efcc86ad0a56b0f0
|
data/gemfiles/libraries.gemfile
CHANGED
data/lib/instana/config.rb
CHANGED
@@ -42,12 +42,23 @@ module Instana
|
|
42
42
|
# ::Instana.config[:collect_backtraces] = true
|
43
43
|
@config[:collect_backtraces] = false
|
44
44
|
|
45
|
+
# By default, collected SQL will be sanitized to remove potentially sensitive bind params such as:
|
46
|
+
# > SELECT "blocks".* FROM "blocks" WHERE "blocks"."name" = "Mr. Smith"
|
47
|
+
#
|
48
|
+
# ...would be sanitized to be:
|
49
|
+
# > SELECT "blocks".* FROM "blocks" WHERE "blocks"."name" = ?
|
50
|
+
#
|
51
|
+
# This sanitization step can be disabled by setting the following value to false.
|
52
|
+
# ::Instana.config[:sanitize_sql] = false
|
53
|
+
@config[:sanitize_sql] = true
|
54
|
+
|
45
55
|
@config[:action_controller] = { :enabled => true }
|
46
56
|
@config[:action_view] = { :enabled => true }
|
47
57
|
@config[:active_record] = { :enabled => true }
|
48
58
|
@config[:dalli] = { :enabled => true }
|
49
59
|
@config[:excon] = { :enabled => true }
|
50
60
|
@config[:grpc] = { :enabled => true }
|
61
|
+
@config[:graphql] = { :enabled => true }
|
51
62
|
@config[:nethttp] = { :enabled => true }
|
52
63
|
@config[:redis] = { :enabled => true }
|
53
64
|
@config[:'resque-client'] = { :enabled => true }
|
@@ -24,7 +24,13 @@ module Instana
|
|
24
24
|
#
|
25
25
|
def collect(sql)
|
26
26
|
payload = { :activerecord => {} }
|
27
|
-
|
27
|
+
|
28
|
+
if ::Instana.config[:sanitize_sql]
|
29
|
+
payload[:activerecord][:sql] = sql.gsub(@@sanitize_regexp, '?')
|
30
|
+
else
|
31
|
+
payload[:activerecord][:sql] = sql
|
32
|
+
end
|
33
|
+
|
28
34
|
payload[:activerecord][:adapter] = @config[:adapter]
|
29
35
|
payload[:activerecord][:host] = @config[:host]
|
30
36
|
payload[:activerecord][:db] = @config[:database]
|
@@ -21,7 +21,13 @@ module Instana
|
|
21
21
|
#
|
22
22
|
def collect(sql)
|
23
23
|
payload = { :activerecord => {} }
|
24
|
-
|
24
|
+
|
25
|
+
if ::Instana.config[:sanitize_sql]
|
26
|
+
payload[:activerecord][:sql] = sql.gsub(@@sanitize_regexp, '?')
|
27
|
+
else
|
28
|
+
payload[:activerecord][:sql] = sql
|
29
|
+
end
|
30
|
+
|
25
31
|
payload[:activerecord][:adapter] = @config[:adapter]
|
26
32
|
payload[:activerecord][:host] = @config[:host]
|
27
33
|
payload[:activerecord][:db] = @config[:database]
|
@@ -17,7 +17,6 @@ module Instana
|
|
17
17
|
Instana::Util.method_alias(klass, :exec_delete)
|
18
18
|
Instana::Util.method_alias(klass, :execute)
|
19
19
|
|
20
|
-
|
21
20
|
@@sanitize_regexp = Regexp.new('(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)', Regexp::IGNORECASE)
|
22
21
|
end
|
23
22
|
end
|
@@ -27,14 +26,33 @@ module Instana
|
|
27
26
|
# @param sql [String]
|
28
27
|
# @return [Hash] Hash of collected KVs
|
29
28
|
#
|
30
|
-
def collect(sql)
|
29
|
+
def collect(sql, binds = nil)
|
31
30
|
payload = { :activerecord => {} }
|
32
|
-
|
31
|
+
|
33
32
|
payload[:activerecord][:adapter] = @config[:adapter]
|
34
33
|
payload[:activerecord][:host] = @config[:host]
|
35
34
|
payload[:activerecord][:db] = @config[:database]
|
36
35
|
payload[:activerecord][:username] = @config[:username]
|
36
|
+
|
37
|
+
if ::Instana.config[:sanitize_sql]
|
38
|
+
payload[:activerecord][:sql] = sql.gsub(@@sanitize_regexp, '?')
|
39
|
+
else
|
40
|
+
# No sanitization so raw SQL and collect up binds
|
41
|
+
payload[:activerecord][:sql] = sql
|
42
|
+
|
43
|
+
# FIXME: Only works on Rails 5 as the bind format varied in previous versions of Rails
|
44
|
+
if binds.is_a?(Array)
|
45
|
+
raw_binds = []
|
46
|
+
binds.each { |x| raw_binds << x.value_before_type_cast }
|
47
|
+
payload[:activerecord][:binds] = raw_binds
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
37
51
|
payload
|
52
|
+
rescue Exception => e
|
53
|
+
::Instana.logger.debug { "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" }
|
54
|
+
ensure
|
55
|
+
return payload
|
38
56
|
end
|
39
57
|
|
40
58
|
# In the spirit of ::ActiveRecord::ExplainSubscriber.ignore_payload? There are
|
@@ -53,7 +71,7 @@ module Instana
|
|
53
71
|
return exec_query_without_instana(sql, name, binds, *args)
|
54
72
|
end
|
55
73
|
|
56
|
-
kv_payload = collect(sql)
|
74
|
+
kv_payload = collect(sql, binds)
|
57
75
|
::Instana.tracer.trace(:activerecord, kv_payload) do
|
58
76
|
exec_query_without_instana(sql, name, binds, *args)
|
59
77
|
end
|
@@ -64,7 +82,7 @@ module Instana
|
|
64
82
|
return exec_delete_without_instana(sql, name, binds)
|
65
83
|
end
|
66
84
|
|
67
|
-
kv_payload = collect(sql)
|
85
|
+
kv_payload = collect(sql, binds)
|
68
86
|
::Instana.tracer.trace(:activerecord, kv_payload) do
|
69
87
|
exec_delete_without_instana(sql, name, binds)
|
70
88
|
end
|
@@ -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
|
@@ -57,9 +57,6 @@ module Instana
|
|
57
57
|
end
|
58
58
|
|
59
59
|
if ::Instana.config[:collect_backtraces]
|
60
|
-
# For entry spans, add a backtrace fingerprint
|
61
|
-
add_stack(limit: 2) if ENTRY_SPANS.include?(name)
|
62
|
-
|
63
60
|
# Attach a backtrace to all exit spans
|
64
61
|
add_stack if EXIT_SPANS.include?(name)
|
65
62
|
end
|
@@ -76,9 +73,11 @@ module Instana
|
|
76
73
|
#
|
77
74
|
# @param limit [Integer] Limit the backtrace to the top <limit> frames
|
78
75
|
#
|
79
|
-
def add_stack(limit:
|
76
|
+
def add_stack(limit: 30, stack: Kernel.caller)
|
80
77
|
frame_count = 0
|
78
|
+
sanitized_stack = []
|
81
79
|
@data[:stack] = []
|
80
|
+
limit = 40 if limit > 40
|
82
81
|
|
83
82
|
stack.each do |i|
|
84
83
|
# If the stack has the full instana gem version in it's path
|
@@ -86,18 +85,23 @@ module Instana
|
|
86
85
|
if !i.match(/instana\/instrumentation\/rack.rb/).nil? ||
|
87
86
|
(i.match(::Instana::VERSION_FULL).nil? && i.match('lib/instana/').nil?)
|
88
87
|
|
89
|
-
break if limit && frame_count >= limit
|
90
|
-
|
91
88
|
x = i.split(':')
|
92
89
|
|
93
|
-
|
90
|
+
sanitized_stack << {
|
94
91
|
:c => x[0],
|
95
92
|
:n => x[1],
|
96
93
|
:m => x[2]
|
97
94
|
}
|
98
|
-
frame_count = frame_count + 1 if limit
|
99
95
|
end
|
100
96
|
end
|
97
|
+
|
98
|
+
if sanitized_stack.length > limit
|
99
|
+
# (limit * -1) gives us negative form of <limit> used for
|
100
|
+
# slicing from the end of the list. e.g. stack[-30, 30]
|
101
|
+
@data[:stack] = sanitized_stack[limit*-1, limit]
|
102
|
+
else
|
103
|
+
@data[:stack] = sanitized_stack
|
104
|
+
end
|
101
105
|
end
|
102
106
|
|
103
107
|
# Log an error into the span
|
data/lib/instana/version.rb
CHANGED
@@ -57,11 +57,7 @@ class RackTest < Minitest::Test
|
|
57
57
|
assert rack_span[:f].key?(:e)
|
58
58
|
assert rack_span[:f].key?(:h)
|
59
59
|
assert_equal ::Instana.agent.agent_uuid, rack_span[:f][:h]
|
60
|
-
|
61
|
-
# Backtrace fingerprint validation
|
62
|
-
assert rack_span.key?(:stack)
|
63
|
-
assert_equal 2, rack_span[:stack].count
|
64
|
-
refute_nil rack_span[:stack].first[:c].match(/instana\/instrumentation\/rack.rb/)
|
60
|
+
assert !rack_span.key?(:stack)
|
65
61
|
|
66
62
|
# Restore to default
|
67
63
|
::Instana.config[:collect_backtraces] = false
|
@@ -233,11 +229,7 @@ class RackTest < Minitest::Test
|
|
233
229
|
assert rack_span[:data][:http][:header].key?(:"X-Capture-This")
|
234
230
|
assert !rack_span[:data][:http][:header].key?(:"X-Capture-That")
|
235
231
|
assert_equal "ThereYouGo", rack_span[:data][:http][:header][:"X-Capture-This"]
|
236
|
-
|
237
|
-
# Backtrace fingerprint validation
|
238
|
-
assert rack_span.key?(:stack)
|
239
|
-
assert_equal 2, rack_span[:stack].count
|
240
|
-
refute_nil rack_span[:stack].first[:c].match(/instana\/instrumentation\/rack.rb/)
|
232
|
+
assert !rack_span.key?(:stack)
|
241
233
|
|
242
234
|
# Restore to default
|
243
235
|
::Instana.config[:collect_backtraces] = false
|
@@ -2,7 +2,14 @@ require 'test_helper'
|
|
2
2
|
require 'active_record'
|
3
3
|
|
4
4
|
class ActiveRecordTest < Minitest::Test
|
5
|
+
|
6
|
+
def teardown
|
7
|
+
# Make sure defaults are back in place
|
8
|
+
::Instana.config[:sanitize_sql] = true
|
9
|
+
end
|
10
|
+
|
5
11
|
def test_config_defaults
|
12
|
+
assert ::Instana.config[:sanitize_sql] == true
|
6
13
|
assert ::Instana.config[:active_record].is_a?(Hash)
|
7
14
|
assert ::Instana.config[:active_record].key?(:enabled)
|
8
15
|
assert_equal true, ::Instana.config[:active_record][:enabled]
|
@@ -28,19 +35,14 @@ class ActiveRecordTest < Minitest::Test
|
|
28
35
|
assert span[:data][:activerecord].key?(:username)
|
29
36
|
end
|
30
37
|
|
31
|
-
|
32
|
-
found = false
|
33
38
|
if ::Rails::VERSION::MAJOR < 4
|
34
39
|
sql = "INSERT INTO \"blocks\" (\"color\", \"created_at\", \"name\", \"updated_at\") VALUES ($?, $?, $?, $?) RETURNING \"id\""
|
35
40
|
else
|
36
41
|
sql = "INSERT INTO \"blocks\" (\"name\", \"color\", \"created_at\", \"updated_at\") VALUES ($?, $?, $?, $?) RETURNING \"id\""
|
37
42
|
end
|
38
|
-
ar_spans
|
39
|
-
|
40
|
-
found = true
|
41
|
-
end
|
43
|
+
ar_span = find_first_span_by_qualifier(ar_spans) do |span|
|
44
|
+
span[:data][:activerecord][:sql] == sql
|
42
45
|
end
|
43
|
-
assert found
|
44
46
|
|
45
47
|
found = false
|
46
48
|
if ::Rails::VERSION::MAJOR >= 5
|
@@ -50,12 +52,9 @@ class ActiveRecordTest < Minitest::Test
|
|
50
52
|
else
|
51
53
|
sql = "SELECT \"blocks\".* FROM \"blocks\" WHERE \"blocks\".\"name\" = ? LIMIT ?"
|
52
54
|
end
|
53
|
-
ar_spans
|
54
|
-
|
55
|
-
found = true
|
56
|
-
end
|
55
|
+
ar_span = find_first_span_by_qualifier(ar_spans) do |span|
|
56
|
+
span[:data][:activerecord][:sql] == sql
|
57
57
|
end
|
58
|
-
assert found
|
59
58
|
|
60
59
|
found = false
|
61
60
|
if ::Rails::VERSION::MAJOR == 3
|
@@ -63,12 +62,73 @@ class ActiveRecordTest < Minitest::Test
|
|
63
62
|
else
|
64
63
|
sql = "DELETE FROM \"blocks\" WHERE \"blocks\".\"id\" = $?"
|
65
64
|
end
|
65
|
+
ar_span = find_first_span_by_qualifier(ar_spans) do |span|
|
66
|
+
span[:data][:activerecord][:sql] == sql
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_postgresql_without_sanitize
|
71
|
+
skip unless ::Instana::Test.postgresql?
|
72
|
+
|
73
|
+
# Shut SQL sanitization off
|
74
|
+
::Instana.config[:sanitize_sql] = false
|
75
|
+
# Pause so the thread can syncronize values
|
76
|
+
sleep 1
|
77
|
+
|
78
|
+
clear_all!
|
79
|
+
|
80
|
+
Net::HTTP.get(URI.parse('http://localhost:3205/test/db'))
|
81
|
+
|
82
|
+
spans = Instana.processor.queued_spans
|
83
|
+
assert_equal 6, spans.length
|
84
|
+
rack_span = find_first_span_by_name(spans, :rack)
|
85
|
+
|
86
|
+
ar_spans = find_spans_by_name(spans, :activerecord)
|
87
|
+
assert_equal 3, ar_spans.length
|
88
|
+
|
66
89
|
ar_spans.each do |span|
|
67
|
-
|
68
|
-
|
69
|
-
|
90
|
+
assert_equal "postgresql", span[:data][:activerecord][:adapter]
|
91
|
+
assert span[:data][:activerecord].key?(:host)
|
92
|
+
assert span[:data][:activerecord].key?(:username)
|
93
|
+
end
|
94
|
+
|
95
|
+
if ::Rails::VERSION::MAJOR < 4
|
96
|
+
sql = "INSERT INTO \"blocks\" (\"color\", \"created_at\", \"name\", \"updated_at\") VALUES ($1, $2, $3, $4) RETURNING \"id\""
|
97
|
+
else
|
98
|
+
sql = "INSERT INTO \"blocks\" (\"name\", \"color\", \"created_at\", \"updated_at\") VALUES ($1, $2, $3, $4) RETURNING \"id\""
|
70
99
|
end
|
71
|
-
|
100
|
+
ar_span = find_first_span_by_qualifier(ar_spans) do |span|
|
101
|
+
span[:data][:activerecord][:sql] == sql
|
102
|
+
end
|
103
|
+
assert ar_span[:data][:activerecord].key?(:binds)
|
104
|
+
assert ar_span[:data][:activerecord][:binds].is_a?(Array)
|
105
|
+
assert_equal 4, ar_span[:data][:activerecord][:binds].length
|
106
|
+
|
107
|
+
if ::Rails::VERSION::MAJOR >= 5
|
108
|
+
sql = "SELECT \"blocks\".* FROM \"blocks\" WHERE \"blocks\".\"name\" = $1 ORDER BY \"blocks\".\"id\" ASC LIMIT $2"
|
109
|
+
elsif ::Rails::VERSION::MAJOR == 4
|
110
|
+
sql = "SELECT \"blocks\".* FROM \"blocks\" WHERE \"blocks\".\"name\" = $? ORDER BY \"blocks\".\"id\" ASC LIMIT ?"
|
111
|
+
else
|
112
|
+
sql = "SELECT \"blocks\".* FROM \"blocks\" WHERE \"blocks\".\"name\" = ? LIMIT ?"
|
113
|
+
end
|
114
|
+
ar_span = find_first_span_by_qualifier(ar_spans) do |span|
|
115
|
+
span[:data][:activerecord][:sql] == sql
|
116
|
+
end
|
117
|
+
assert ar_span[:data][:activerecord].key?(:binds)
|
118
|
+
assert ar_span[:data][:activerecord][:binds].is_a?(Array)
|
119
|
+
assert_equal 2, ar_span[:data][:activerecord][:binds].length
|
120
|
+
|
121
|
+
if ::Rails::VERSION::MAJOR == 3
|
122
|
+
sql = "DELETE FROM \"blocks\" WHERE \"blocks\".\"id\" = 1"
|
123
|
+
else
|
124
|
+
sql = "DELETE FROM \"blocks\" WHERE \"blocks\".\"id\" = $1"
|
125
|
+
end
|
126
|
+
ar_span = find_first_span_by_qualifier(ar_spans) do |span|
|
127
|
+
span[:data][:activerecord][:sql] == sql
|
128
|
+
end
|
129
|
+
assert ar_span[:data][:activerecord].key?(:binds)
|
130
|
+
assert ar_span[:data][:activerecord][:binds].is_a?(Array)
|
131
|
+
assert_equal 1, ar_span[:data][:activerecord][:binds].length
|
72
132
|
end
|
73
133
|
|
74
134
|
def test_postgresql_lock_table
|
@@ -93,21 +153,13 @@ class ActiveRecordTest < Minitest::Test
|
|
93
153
|
assert_equal "postgres", ar_span[:data][:activerecord][:username]
|
94
154
|
end
|
95
155
|
|
96
|
-
|
97
|
-
|
98
|
-
if span[:data][:activerecord][:sql] == "LOCK blocks IN ACCESS EXCLUSIVE MODE"
|
99
|
-
found = true
|
100
|
-
end
|
156
|
+
ar_span = find_first_span_by_qualifier(ar_spans) do |span|
|
157
|
+
span[:data][:activerecord][:sql] == "LOCK blocks IN ACCESS EXCLUSIVE MODE"
|
101
158
|
end
|
102
|
-
assert found
|
103
159
|
|
104
|
-
|
105
|
-
|
106
|
-
if span[:data][:activerecord][:sql] == "SELECT ?"
|
107
|
-
found = true
|
108
|
-
end
|
160
|
+
ar_span = find_first_span_by_qualifier(ar_spans) do |span|
|
161
|
+
span[:data][:activerecord][:sql] == "SELECT ?"
|
109
162
|
end
|
110
|
-
assert found
|
111
163
|
end
|
112
164
|
|
113
165
|
def test_postgresql_raw_execute
|
@@ -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
|
@@ -20,6 +20,16 @@ class RedisTest < Minitest::Test
|
|
20
20
|
assert_redis_trace('SET')
|
21
21
|
end
|
22
22
|
|
23
|
+
def test_georadius
|
24
|
+
clear_all!
|
25
|
+
|
26
|
+
Instana.tracer.start_or_continue_trace(:redis_test) do
|
27
|
+
@redis_client.georadius('Sicily', '15', '37', '200', 'km', 'WITHCOORD', 'WITHDIST')
|
28
|
+
end
|
29
|
+
|
30
|
+
assert_redis_trace('GEORADIUS')
|
31
|
+
end
|
32
|
+
|
23
33
|
def test_normal_call_with_error
|
24
34
|
clear_all!
|
25
35
|
|
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.192.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
|