instana 1.192.1 → 1.193.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/instana/frameworks/instrumentation/abstract_mysql_adapter.rb +5 -7
- data/lib/instana/frameworks/instrumentation/action_view.rb +6 -10
- data/lib/instana/frameworks/instrumentation/active_record.rb +4 -4
- data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +10 -14
- data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +4 -6
- data/lib/instana/frameworks/instrumentation/postgresql_adapter.rb +10 -14
- data/lib/instana/instrumentation/dalli.rb +9 -14
- data/lib/instana/instrumentation/grpc.rb +72 -62
- data/lib/instana/instrumentation/net-http.rb +44 -45
- data/lib/instana/instrumentation/redis.rb +15 -18
- data/lib/instana/instrumentation/resque.rb +17 -28
- data/lib/instana/instrumentation/rest-client.rb +3 -13
- data/lib/instana/secrets.rb +7 -7
- data/lib/instana/util.rb +1 -41
- data/lib/instana/version.rb +1 -1
- data/test/test_helper.rb +3 -9
- 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: 26ea11d0efe2f26610441700b71bc9c2abd4192566a86d00089d1e889d8457d3
|
4
|
+
data.tar.gz: 5dde944418b1f34391c08114692b4f34d27acc8328e0d7bd47c7b14834e21d61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11c700d01ab267b978d527dd9fcc993b5ae19bb659074690ced25b12f34d1b58c850c241776b3c8932a274138170d885e7f9a0c28b430bc382a81c0df3b99451
|
7
|
+
data.tar.gz: 8e4dd40a1d9f87e00905eca337189870f3e8237ce33b3be80853d85e7b11667243fe1e5ca7c6e126b492e0c2ba5d404257bfa908e50984f40d184a65f1067239
|
@@ -6,10 +6,8 @@ module Instana
|
|
6
6
|
|
7
7
|
# This module supports instrumenting ActiveRecord with the mysql2 adapter.
|
8
8
|
#
|
9
|
-
def self.
|
9
|
+
def self.prepended(klass)
|
10
10
|
if ActiveRecord::VERSION::STRING >= '3.2'
|
11
|
-
Instana::Util.method_alias(klass, :execute)
|
12
|
-
|
13
11
|
@@sanitize_regexp = Regexp.new('(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)', Regexp::IGNORECASE)
|
14
12
|
end
|
15
13
|
end
|
@@ -40,17 +38,17 @@ module Instana
|
|
40
38
|
IGNORED_PAYLOADS.include?(name) || sql !~ EXPLAINED_SQLS
|
41
39
|
end
|
42
40
|
|
43
|
-
def
|
41
|
+
def execute(sql, name = nil)
|
44
42
|
tracing = ::Instana.tracer.tracing?
|
45
43
|
if !tracing || ignore_payload?(name, sql)
|
46
|
-
return
|
44
|
+
return super(sql, name)
|
47
45
|
elsif ::Instana.tracer.current_span[:n] == :activerecord
|
48
|
-
return
|
46
|
+
return super(sql, name)
|
49
47
|
end
|
50
48
|
|
51
49
|
kv_payload = collect(sql)
|
52
50
|
::Instana.tracer.trace(:activerecord, kv_payload) do
|
53
|
-
|
51
|
+
super(sql, name)
|
54
52
|
end
|
55
53
|
end
|
56
54
|
end
|
@@ -1,18 +1,13 @@
|
|
1
1
|
module Instana
|
2
2
|
module Instrumentation
|
3
3
|
module ActionViewRenderer
|
4
|
-
def
|
5
|
-
::Instana::Util.method_alias(klass, :render_partial)
|
6
|
-
::Instana::Util.method_alias(klass, :render_collection)
|
7
|
-
end
|
8
|
-
|
9
|
-
def render_partial_with_instana(*args)
|
4
|
+
def render_partial(*args)
|
10
5
|
kv_payload = { :render => {} }
|
11
6
|
kv_payload[:render][:type] = :partial
|
12
7
|
kv_payload[:render][:name] = @options[:partial].to_s if @options.is_a?(Hash)
|
13
8
|
|
14
9
|
::Instana.tracer.log_entry(:render, kv_payload)
|
15
|
-
|
10
|
+
super(*args)
|
16
11
|
rescue Exception => e
|
17
12
|
::Instana.tracer.log_error(e)
|
18
13
|
raise
|
@@ -20,13 +15,14 @@ module Instana
|
|
20
15
|
::Instana.tracer.log_exit(:render)
|
21
16
|
end
|
22
17
|
|
23
|
-
def
|
18
|
+
def render_collection(*args)
|
19
|
+
puts 'called'
|
24
20
|
kv_payload = { :render => {} }
|
25
21
|
kv_payload[:render][:type] = :collection
|
26
22
|
kv_payload[:render][:name] = @path.to_s
|
27
23
|
|
28
24
|
::Instana.tracer.log_entry(:render, kv_payload)
|
29
|
-
|
25
|
+
super(*args)
|
30
26
|
rescue Exception => e
|
31
27
|
::Instana.tracer.log_error(e)
|
32
28
|
raise
|
@@ -39,5 +35,5 @@ end
|
|
39
35
|
|
40
36
|
if defined?(::ActionView) && ::Instana.config[:action_view][:enabled] && ::ActionPack::VERSION::STRING >= '3.1'
|
41
37
|
::Instana.logger.debug "Instrumenting ActionView"
|
42
|
-
::ActionView::PartialRenderer.send(:
|
38
|
+
::ActionView::PartialRenderer.send(:prepend, ::Instana::Instrumentation::ActionViewRenderer)
|
43
39
|
end
|
@@ -9,19 +9,19 @@ if defined?(::ActiveRecord) && ::Instana.config[:active_record][:enabled]
|
|
9
9
|
# Mysql
|
10
10
|
if defined?(ActiveRecord::ConnectionAdapters::MysqlAdapter)
|
11
11
|
::Instana.logger.debug "Instrumenting ActiveRecord (mysql)"
|
12
|
-
ActiveRecord::ConnectionAdapters::MysqlAdapter.send(:
|
13
|
-
ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.send(:
|
12
|
+
ActiveRecord::ConnectionAdapters::MysqlAdapter.send(:prepend, ::Instana::Instrumentation::MysqlAdapter)
|
13
|
+
ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.send(:prepend, ::Instana::Instrumentation::AbstractMysqlAdapter)
|
14
14
|
end
|
15
15
|
|
16
16
|
# Mysql2
|
17
17
|
if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
|
18
18
|
::Instana.logger.debug "Instrumenting ActiveRecord (mysql2)"
|
19
|
-
ActiveRecord::ConnectionAdapters::Mysql2Adapter.send(:
|
19
|
+
ActiveRecord::ConnectionAdapters::Mysql2Adapter.send(:prepend, ::Instana::Instrumentation::Mysql2Adapter)
|
20
20
|
end
|
21
21
|
|
22
22
|
# Postgres
|
23
23
|
if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
|
24
24
|
::Instana.logger.debug "Instrumenting ActiveRecord (postgresql)"
|
25
|
-
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:
|
25
|
+
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:prepend, ::Instana::Instrumentation::PostgreSQLAdapter)
|
26
26
|
end
|
27
27
|
end
|
@@ -6,13 +6,9 @@ module Instana
|
|
6
6
|
|
7
7
|
# This module supports instrumenting ActiveRecord with the mysql2 adapter.
|
8
8
|
#
|
9
|
-
def self.
|
9
|
+
def self.prepended(klass)
|
10
10
|
# ActiveRecord 3.1 and up only (for now possibly)
|
11
11
|
if ActiveRecord::VERSION::STRING > '3.0'
|
12
|
-
Instana::Util.method_alias(klass, :exec_delete)
|
13
|
-
Instana::Util.method_alias(klass, :exec_insert)
|
14
|
-
Instana::Util.method_alias(klass, :exec_query)
|
15
|
-
|
16
12
|
@@sanitize_regexp = Regexp.new('(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)', Regexp::IGNORECASE)
|
17
13
|
end
|
18
14
|
end
|
@@ -49,37 +45,37 @@ module Instana
|
|
49
45
|
IGNORED_PAYLOADS.include?(name) || sql !~ EXPLAINED_SQLS
|
50
46
|
end
|
51
47
|
|
52
|
-
def
|
48
|
+
def exec_delete(sql, name = nil, binds = [])
|
53
49
|
if !::Instana.tracer.tracing? || ignore_payload?(name, sql)
|
54
|
-
return
|
50
|
+
return super(sql, name, binds)
|
55
51
|
end
|
56
52
|
|
57
53
|
kv_payload = collect(sql)
|
58
54
|
::Instana.tracer.trace(:activerecord, kv_payload) do
|
59
|
-
|
55
|
+
super(sql, name, binds)
|
60
56
|
end
|
61
57
|
end
|
62
58
|
|
63
|
-
def
|
59
|
+
def exec_insert(sql, name = 'SQL', binds = [], *args)
|
64
60
|
if !::Instana.tracer.tracing? || ignore_payload?(name, sql)
|
65
|
-
return
|
61
|
+
return super(sql, name, binds, *args)
|
66
62
|
end
|
67
63
|
|
68
64
|
kv_payload = collect(sql)
|
69
65
|
::Instana.tracer.trace(:activerecord, kv_payload) do
|
70
|
-
|
66
|
+
super(sql, name, binds, *args)
|
71
67
|
end
|
72
68
|
end
|
73
69
|
|
74
|
-
def
|
70
|
+
def exec_query(sql, name = 'SQL', binds = [], *args)
|
75
71
|
if !::Instana.tracer.tracing? || ignore_payload?(name, sql) ||
|
76
72
|
::Instana.tracer.current_span[:n] == :activerecord
|
77
|
-
return
|
73
|
+
return super(sql, name, binds, *args)
|
78
74
|
end
|
79
75
|
|
80
76
|
kv_payload = collect(sql)
|
81
77
|
::Instana.tracer.trace(:activerecord, kv_payload) do
|
82
|
-
|
78
|
+
super(sql, name, binds, *args)
|
83
79
|
end
|
84
80
|
end
|
85
81
|
end
|
@@ -6,10 +6,8 @@ module Instana
|
|
6
6
|
|
7
7
|
# This module supports instrumenting ActiveRecord with the mysql2 adapter.
|
8
8
|
#
|
9
|
-
def self.
|
9
|
+
def self.prepended(klass)
|
10
10
|
if ActiveRecord::VERSION::STRING >= '3.2'
|
11
|
-
Instana::Util.method_alias(klass, :exec_query)
|
12
|
-
|
13
11
|
@@sanitize_regexp = Regexp.new('(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)', Regexp::IGNORECASE)
|
14
12
|
end
|
15
13
|
end
|
@@ -46,15 +44,15 @@ module Instana
|
|
46
44
|
IGNORED_PAYLOADS.include?(name) || sql !~ EXPLAINED_SQLS
|
47
45
|
end
|
48
46
|
|
49
|
-
def
|
47
|
+
def exec_query(sql, name = 'SQL', binds = [], *args)
|
50
48
|
if !::Instana.tracer.tracing? || ignore_payload?(name, sql) ||
|
51
49
|
::Instana.tracer.current_span[:n] == :activerecord
|
52
|
-
return
|
50
|
+
return super(sql, name, binds, *args)
|
53
51
|
end
|
54
52
|
|
55
53
|
kv_payload = collect(sql)
|
56
54
|
::Instana.tracer.trace(:activerecord, kv_payload) do
|
57
|
-
|
55
|
+
super(sql, name, binds, *args)
|
58
56
|
end
|
59
57
|
end
|
60
58
|
end
|
@@ -8,15 +8,11 @@ module Instana
|
|
8
8
|
# This module supports instrumenting ActiveRecord with the postgresql adapter. Only
|
9
9
|
# versions >= 3.1 are supported.
|
10
10
|
#
|
11
|
-
def self.
|
11
|
+
def self.prepended(klass)
|
12
12
|
if (::ActiveRecord::VERSION::MAJOR == 3 && ::ActiveRecord::VERSION::MINOR > 0) ||
|
13
13
|
::ActiveRecord::VERSION::MAJOR >= 4
|
14
14
|
|
15
15
|
# ActiveRecord 3.1 and up
|
16
|
-
Instana::Util.method_alias(klass, :exec_query)
|
17
|
-
Instana::Util.method_alias(klass, :exec_delete)
|
18
|
-
Instana::Util.method_alias(klass, :execute)
|
19
|
-
|
20
16
|
@@sanitize_regexp = Regexp.new('(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)', Regexp::IGNORECASE)
|
21
17
|
end
|
22
18
|
end
|
@@ -66,36 +62,36 @@ module Instana
|
|
66
62
|
IGNORED_PAYLOADS.include?(name) || IGNORED_SQL.include?(sql)
|
67
63
|
end
|
68
64
|
|
69
|
-
def
|
65
|
+
def exec_query(sql, name = 'SQL', binds = [], *args)
|
70
66
|
if !::Instana.tracer.tracing? || ignore_payload?(name, sql)
|
71
|
-
return
|
67
|
+
return super(sql, name, binds, *args)
|
72
68
|
end
|
73
69
|
|
74
70
|
kv_payload = collect(sql, binds)
|
75
71
|
::Instana.tracer.trace(:activerecord, kv_payload) do
|
76
|
-
|
72
|
+
super(sql, name, binds, *args)
|
77
73
|
end
|
78
74
|
end
|
79
75
|
|
80
|
-
def
|
76
|
+
def exec_delete(sql, name = nil, binds = [])
|
81
77
|
if !::Instana.tracer.tracing? || ignore_payload?(name, sql)
|
82
|
-
return
|
78
|
+
return super(sql, name, binds)
|
83
79
|
end
|
84
80
|
|
85
81
|
kv_payload = collect(sql, binds)
|
86
82
|
::Instana.tracer.trace(:activerecord, kv_payload) do
|
87
|
-
|
83
|
+
super(sql, name, binds)
|
88
84
|
end
|
89
85
|
end
|
90
86
|
|
91
|
-
def
|
87
|
+
def execute(sql, name = nil)
|
92
88
|
if !::Instana.tracer.tracing? || ignore_payload?(name, sql)
|
93
|
-
return
|
89
|
+
return super(sql, name)
|
94
90
|
end
|
95
91
|
|
96
92
|
kv_payload = collect(sql)
|
97
93
|
::Instana.tracer.trace(:activerecord, kv_payload) do
|
98
|
-
|
94
|
+
super(sql, name)
|
99
95
|
end
|
100
96
|
end
|
101
97
|
end
|
@@ -1,15 +1,10 @@
|
|
1
1
|
module Instana
|
2
2
|
module Instrumentation
|
3
3
|
module Dalli
|
4
|
-
def
|
5
|
-
::Instana::Util.method_alias(klass, :perform)
|
6
|
-
::Instana::Util.method_alias(klass, :get_multi)
|
7
|
-
end
|
8
|
-
|
9
|
-
def perform_with_instana(*args, &blk)
|
4
|
+
def perform(*args, &blk)
|
10
5
|
if !::Instana.tracer.tracing? || ::Instana.tracer.tracing_span?(:memcache)
|
11
6
|
do_skip = true
|
12
|
-
return
|
7
|
+
return super(*args, &blk)
|
13
8
|
end
|
14
9
|
|
15
10
|
op, key, *_opts = args
|
@@ -22,7 +17,7 @@ module Instana
|
|
22
17
|
::Instana.tracer.log_entry(:memcache, entry_payload)
|
23
18
|
exit_payload = { :memcache => {} }
|
24
19
|
|
25
|
-
result =
|
20
|
+
result = super(*args, &blk)
|
26
21
|
|
27
22
|
if op == :get
|
28
23
|
exit_payload[:memcache][:hit] = result ? 1 : 0
|
@@ -36,7 +31,7 @@ module Instana
|
|
36
31
|
::Instana.tracer.log_exit(:memcache, exit_payload) unless do_skip
|
37
32
|
end
|
38
33
|
|
39
|
-
def
|
34
|
+
def get_multi(*keys)
|
40
35
|
entry_payload = { :memcache => {} }
|
41
36
|
entry_payload[:memcache][:namespace] = @options[:namespace] if @options.key?(:namespace)
|
42
37
|
entry_payload[:memcache][:command] = :get_multi
|
@@ -45,7 +40,7 @@ module Instana
|
|
45
40
|
::Instana.tracer.log_entry(:memcache, entry_payload)
|
46
41
|
exit_payload = { :memcache => {} }
|
47
42
|
|
48
|
-
result =
|
43
|
+
result = super(*keys)
|
49
44
|
|
50
45
|
exit_payload[:memcache][:hits] = result.length
|
51
46
|
result
|
@@ -63,13 +58,13 @@ module Instana
|
|
63
58
|
::Instana::Util.method_alias(klass, :request)
|
64
59
|
end
|
65
60
|
|
66
|
-
def
|
61
|
+
def request(op, *args)
|
67
62
|
if ::Instana.tracer.tracing? || ::Instana.tracer.tracing_span?(:memcache)
|
68
63
|
info_payload = { :memcache => {} }
|
69
64
|
info_payload[:memcache][:server] = "#{@hostname}:#{@port}"
|
70
65
|
::Instana.tracer.log_info(info_payload)
|
71
66
|
end
|
72
|
-
|
67
|
+
super(op, *args)
|
73
68
|
end
|
74
69
|
end
|
75
70
|
end
|
@@ -77,6 +72,6 @@ end
|
|
77
72
|
|
78
73
|
if defined?(::Dalli) && ::Instana.config[:dalli][:enabled]
|
79
74
|
::Instana.logger.debug "Instrumenting Dalli"
|
80
|
-
::Dalli::Client.send(:
|
81
|
-
::Dalli::Server.send(:
|
75
|
+
::Dalli::Client.send(:prepend, ::Instana::Instrumentation::Dalli)
|
76
|
+
::Dalli::Server.send(:prepend, ::Instana::Instrumentation::DalliServer)
|
82
77
|
end
|
@@ -1,84 +1,94 @@
|
|
1
1
|
call_types = [:request_response, :client_streamer, :server_streamer, :bidi_streamer]
|
2
2
|
|
3
3
|
if defined?(GRPC::ActiveCall) && ::Instana.config[:grpc][:enabled]
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
kvs = { rpc: {} }
|
4
|
+
module Instana
|
5
|
+
module GRPCCientInstrumentation
|
6
|
+
CALL_TYPES = [:request_response, :client_streamer, :server_streamer, :bidi_streamer]
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
CALL_TYPES.each do |call_type|
|
9
|
+
define_method(call_type) do |method, *others, **options|
|
10
|
+
begin
|
11
|
+
kvs = { rpc: {} }
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
kvs[:rpc][:call_type] = :#{call_type}
|
13
|
+
unless ::Instana.tracer.tracing?
|
14
|
+
return super(method, *others, **options)
|
15
|
+
end
|
17
16
|
|
18
|
-
|
17
|
+
kvs[:rpc][:flavor] = :grpc
|
18
|
+
kvs[:rpc][:host] = @host
|
19
|
+
kvs[:rpc][:call] = method
|
20
|
+
kvs[:rpc][:call_type] = call_type
|
19
21
|
|
20
|
-
|
21
|
-
if context
|
22
|
-
options[:metadata] = (options[:metadata] || {}).merge(
|
23
|
-
'x-instana-t' => context.trace_id_header,
|
24
|
-
'x-instana-s' => context.span_id_header
|
25
|
-
)
|
26
|
-
end
|
22
|
+
::Instana.tracer.log_entry(:'rpc-client', kvs)
|
27
23
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
::Instana.tracer.log_exit(:'rpc-client', {})
|
36
|
-
end
|
24
|
+
context = ::Instana.tracer.context
|
25
|
+
if context
|
26
|
+
options[:metadata] = (options[:metadata] || {}).merge(
|
27
|
+
'x-instana-t' => context.trace_id_header,
|
28
|
+
'x-instana-s' => context.span_id_header
|
29
|
+
)
|
30
|
+
end
|
37
31
|
|
38
|
-
|
39
|
-
|
40
|
-
|
32
|
+
super(method, *others, **options)
|
33
|
+
rescue => e
|
34
|
+
kvs[:rpc][:error] = true
|
35
|
+
::Instana.tracer.log_info(kvs)
|
36
|
+
::Instana.tracer.log_error(e)
|
37
|
+
raise
|
38
|
+
ensure
|
39
|
+
::Instana.tracer.log_exit(:'rpc-client', {})
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
41
44
|
end
|
45
|
+
|
42
46
|
::Instana.logger.debug 'Instrumenting GRPC client'
|
47
|
+
::GRPC::ClientStub.prepend(::Instana::GRPCCientInstrumentation)
|
43
48
|
end
|
44
49
|
|
45
50
|
if defined?(GRPC::RpcDesc) && ::Instana.config[:grpc][:enabled]
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
kvs = { rpc: {} }
|
50
|
-
metadata = active_call.metadata
|
51
|
+
module Instana
|
52
|
+
module GRPCServerInstrumentation
|
53
|
+
CALL_TYPES = [:request_response, :client_streamer, :server_streamer, :bidi_streamer]
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
55
|
+
CALL_TYPES.each do |call_type|
|
56
|
+
define_method(:"handle_#{call_type}") do |active_call, mth, *others|
|
57
|
+
begin
|
58
|
+
kvs = { rpc: {} }
|
59
|
+
metadata = active_call.metadata
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
incoming_context = {}
|
62
|
+
if metadata.key?('x-instana-t')
|
63
|
+
incoming_context[:trace_id] = ::Instana::Util.header_to_id(metadata['x-instana-t'])
|
64
|
+
incoming_context[:span_id] = ::Instana::Util.header_to_id(metadata['x-instana-s']) if metadata.key?('x-instana-s')
|
65
|
+
incoming_context[:level] = metadata['x-instana-l'] if metadata.key?('x-instana-l')
|
66
|
+
end
|
64
67
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
+
kvs[:rpc][:flavor] = :grpc
|
69
|
+
kvs[:rpc][:host] = Socket.gethostname
|
70
|
+
kvs[:rpc][:call] = "/#{mth.owner.service_name}/#{name}"
|
71
|
+
kvs[:rpc][:call_type] = call_type
|
72
|
+
kvs[:rpc][:peer] = { address: active_call.peer }
|
68
73
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
::Instana.tracer.log_info(kvs)
|
73
|
-
::Instana.tracer.log_error(e)
|
74
|
-
raise
|
75
|
-
ensure
|
76
|
-
::Instana.tracer.log_end(:'rpc-server', {}) if ::Instana.tracer.tracing?
|
77
|
-
end
|
74
|
+
::Instana.tracer.log_start_or_continue(
|
75
|
+
:'rpc-server', kvs, incoming_context
|
76
|
+
)
|
78
77
|
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
super(active_call, mth, *others)
|
79
|
+
rescue => e
|
80
|
+
kvs[:rpc][:error] = true
|
81
|
+
::Instana.tracer.log_info(kvs)
|
82
|
+
::Instana.tracer.log_error(e)
|
83
|
+
raise
|
84
|
+
ensure
|
85
|
+
::Instana.tracer.log_end(:'rpc-server', {}) if ::Instana.tracer.tracing?
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
82
90
|
end
|
91
|
+
|
83
92
|
::Instana.logger.debug 'Instrumenting GRPC server'
|
93
|
+
::GRPC::RpcDesc.prepend(::Instana::GRPCServerInstrumentation)
|
84
94
|
end
|
@@ -1,61 +1,60 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
|
3
3
|
if defined?(::Net::HTTP) && ::Instana.config[:nethttp][:enabled]
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
module Instana
|
5
|
+
module NetHTTPInstrumentation
|
6
|
+
def request(*args, &block)
|
7
|
+
if !Instana.tracer.tracing? || !started?
|
8
|
+
do_skip = true
|
9
|
+
return super(*args, &block)
|
10
|
+
end
|
11
11
|
|
12
|
-
|
12
|
+
::Instana.tracer.log_entry(:'net-http')
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
# Send out the tracing context with the request
|
15
|
+
request = args[0]
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
# Set request headers; encode IDs as hexadecimal strings
|
18
|
+
t_context = ::Instana.tracer.context
|
19
|
+
request['X-Instana-T'] = t_context.trace_id_header
|
20
|
+
request['X-Instana-S'] = t_context.span_id_header
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
# Collect up KV info now in case any exception is raised
|
23
|
+
kv_payload = { :http => {} }
|
24
|
+
kv_payload[:http][:method] = request.method
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
else
|
29
|
-
if use_ssl?
|
30
|
-
kv_payload[:http][:url] = "https://#{@address}:#{@port}#{request.path}"
|
26
|
+
if request.uri
|
27
|
+
kv_payload[:http][:url] = request.uri.to_s
|
31
28
|
else
|
32
|
-
|
29
|
+
if use_ssl?
|
30
|
+
kv_payload[:http][:url] = "https://#{@address}:#{@port}#{request.path}"
|
31
|
+
else
|
32
|
+
kv_payload[:http][:url] = "http://#{@address}:#{@port}#{request.path}"
|
33
|
+
end
|
33
34
|
end
|
34
|
-
end
|
35
|
-
|
36
|
-
kv_payload[:http][:url] = ::Instana.secrets.remove_from_query(kv_payload[:http][:url])
|
37
35
|
|
38
|
-
|
39
|
-
response = request_without_instana(*args, &block)
|
36
|
+
kv_payload[:http][:url] = ::Instana.secrets.remove_from_query(kv_payload[:http][:url])
|
40
37
|
|
41
|
-
|
42
|
-
|
43
|
-
# Because of the 5xx response, we flag this span as errored but
|
44
|
-
# without a backtrace (no exception)
|
45
|
-
::Instana.tracer.log_error(nil)
|
46
|
-
end
|
38
|
+
# The core call
|
39
|
+
response = super(*args, &block)
|
47
40
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
41
|
+
kv_payload[:http][:status] = response.code
|
42
|
+
if response.code.to_i.between?(500, 511)
|
43
|
+
# Because of the 5xx response, we flag this span as errored but
|
44
|
+
# without a backtrace (no exception)
|
45
|
+
::Instana.tracer.log_error(nil)
|
46
|
+
end
|
55
47
|
|
56
|
-
|
48
|
+
response
|
49
|
+
rescue => e
|
50
|
+
::Instana.tracer.log_error(e)
|
51
|
+
raise
|
52
|
+
ensure
|
53
|
+
::Instana.tracer.log_exit(:'net-http', kv_payload) unless do_skip
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
}
|
58
|
+
::Instana.logger.debug "Instrumenting Net::HTTP"
|
59
|
+
Net::HTTP.prepend(::Instana::NetHTTPInstrumentation)
|
61
60
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
def
|
1
|
+
module Instana
|
2
|
+
module RedisInstrumentation
|
3
|
+
def call(*args, &block)
|
4
4
|
kv_payload = { redis: {} }
|
5
5
|
dnt_spans = [:redis, :'resque-client', :'sidekiq-client']
|
6
6
|
|
7
|
-
if !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name)
|
8
|
-
return
|
7
|
+
if !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name) || !Instana.config[:redis][:enabled]
|
8
|
+
return super(*args, &block)
|
9
9
|
end
|
10
10
|
|
11
11
|
begin
|
@@ -19,7 +19,7 @@ if defined?(::Redis) && ::Instana.config[:redis][:enabled]
|
|
19
19
|
nil
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
super(*args, &block)
|
23
23
|
rescue => e
|
24
24
|
::Instana.tracer.log_info({ redis: {error: true} })
|
25
25
|
::Instana.tracer.log_error(e)
|
@@ -29,17 +29,12 @@ if defined?(::Redis) && ::Instana.config[:redis][:enabled]
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
alias call_without_instana call
|
35
|
-
alias call call_with_instana
|
36
|
-
|
37
|
-
def call_pipeline_with_instana(*args, &block)
|
32
|
+
def call_pipeline(*args, &block)
|
38
33
|
kv_payload = { redis: {} }
|
39
34
|
dnt_spans = [:redis, :'resque-client', :'sidekiq-client']
|
40
35
|
|
41
|
-
if !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name)
|
42
|
-
return
|
36
|
+
if !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name) || !Instana.config[:redis][:enabled]
|
37
|
+
return super(*args, &block)
|
43
38
|
end
|
44
39
|
|
45
40
|
begin
|
@@ -54,7 +49,7 @@ if defined?(::Redis) && ::Instana.config[:redis][:enabled]
|
|
54
49
|
nil
|
55
50
|
end
|
56
51
|
|
57
|
-
|
52
|
+
super(*args, &block)
|
58
53
|
rescue => e
|
59
54
|
::Instana.tracer.log_info({ redis: {error: true} })
|
60
55
|
::Instana.tracer.log_error(e)
|
@@ -63,8 +58,10 @@ if defined?(::Redis) && ::Instana.config[:redis][:enabled]
|
|
63
58
|
::Instana.tracer.log_exit(:redis, kv_payload)
|
64
59
|
end
|
65
60
|
end
|
66
|
-
|
67
|
-
alias call_pipeline_without_instana call_pipeline
|
68
|
-
alias call_pipeline call_pipeline_with_instana
|
69
61
|
end
|
70
62
|
end
|
63
|
+
|
64
|
+
if defined?(::Redis) && ::Instana.config[:redis][:enabled]
|
65
|
+
::Instana.logger.debug "Instrumenting Redis"
|
66
|
+
Redis::Client.prepend(::Instana::RedisInstrumentation)
|
67
|
+
end
|
@@ -3,11 +3,8 @@ require 'socket'
|
|
3
3
|
module Instana
|
4
4
|
module Instrumentation
|
5
5
|
module ResqueClient
|
6
|
-
def self.
|
6
|
+
def self.prepended(klass)
|
7
7
|
klass.send :extend, ::Resque
|
8
|
-
::Instana::Util.method_alias(klass, :enqueue)
|
9
|
-
::Instana::Util.method_alias(klass, :enqueue_to)
|
10
|
-
::Instana::Util.method_alias(klass, :dequeue)
|
11
8
|
end
|
12
9
|
|
13
10
|
def collect_kvs(op, klass, args)
|
@@ -23,50 +20,46 @@ module Instana
|
|
23
20
|
{ :'resque-client' => kvs }
|
24
21
|
end
|
25
22
|
|
26
|
-
def
|
23
|
+
def enqueue(klass, *args)
|
27
24
|
if Instana.tracer.tracing?
|
28
25
|
kvs = collect_kvs(:enqueue, klass, args)
|
29
26
|
|
30
27
|
Instana.tracer.trace(:'resque-client', kvs) do
|
31
|
-
|
28
|
+
super(klass, *args)
|
32
29
|
end
|
33
30
|
else
|
34
|
-
|
31
|
+
super(klass, *args)
|
35
32
|
end
|
36
33
|
end
|
37
34
|
|
38
|
-
def
|
35
|
+
def enqueue_to(queue, klass, *args)
|
39
36
|
if Instana.tracer.tracing? && !Instana.tracer.tracing_span?(:'resque-client')
|
40
37
|
kvs = collect_kvs(:enqueue_to, klass, args)
|
41
38
|
kvs[:Queue] = queue.to_s if queue
|
42
39
|
|
43
40
|
Instana.tracer.trace(:'resque-client', kvs) do
|
44
|
-
|
41
|
+
super(queue, klass, *args)
|
45
42
|
end
|
46
43
|
else
|
47
|
-
|
44
|
+
super(queue, klass, *args)
|
48
45
|
end
|
49
46
|
end
|
50
47
|
|
51
|
-
def
|
48
|
+
def dequeue(klass, *args)
|
52
49
|
if Instana.tracer.tracing?
|
53
50
|
kvs = collect_kvs(:dequeue, klass, args)
|
54
51
|
|
55
52
|
Instana.tracer.trace(:'resque-client', kvs) do
|
56
|
-
|
53
|
+
super(klass, *args)
|
57
54
|
end
|
58
55
|
else
|
59
|
-
|
56
|
+
super(klass, *args)
|
60
57
|
end
|
61
58
|
end
|
62
59
|
end
|
63
60
|
|
64
61
|
module ResqueWorker
|
65
|
-
def
|
66
|
-
::Instana::Util.method_alias(klass, :perform)
|
67
|
-
end
|
68
|
-
|
69
|
-
def perform_with_instana(job)
|
62
|
+
def perform(job)
|
70
63
|
kvs = {}
|
71
64
|
kvs[:'resque-worker'] = {}
|
72
65
|
|
@@ -81,17 +74,13 @@ module Instana
|
|
81
74
|
end
|
82
75
|
|
83
76
|
Instana.tracer.start_or_continue_trace(:'resque-worker', kvs) do
|
84
|
-
|
77
|
+
super(job)
|
85
78
|
end
|
86
79
|
end
|
87
80
|
end
|
88
81
|
|
89
82
|
module ResqueJob
|
90
|
-
def
|
91
|
-
::Instana::Util.method_alias(klass, :fail)
|
92
|
-
end
|
93
|
-
|
94
|
-
def fail_with_instana(exception)
|
83
|
+
def fail(exception)
|
95
84
|
if Instana.tracer.tracing?
|
96
85
|
::Instana.tracer.log_info(:'resque-worker' => { :error => "#{exception.class}: #{exception}"})
|
97
86
|
::Instana.tracer.log_error(exception)
|
@@ -99,7 +88,7 @@ module Instana
|
|
99
88
|
rescue Exception => e
|
100
89
|
::Instana.logger.debug { "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" } if Instana::Config[:verbose]
|
101
90
|
ensure
|
102
|
-
|
91
|
+
super(exception)
|
103
92
|
end
|
104
93
|
end
|
105
94
|
end
|
@@ -109,14 +98,14 @@ if defined?(::Resque) && RUBY_VERSION >= '1.9.3'
|
|
109
98
|
|
110
99
|
if ::Instana.config[:'resque-client'][:enabled]
|
111
100
|
::Instana.logger.debug 'Instrumenting Resque Client'
|
112
|
-
::
|
101
|
+
::Resque.prepend(::Instana::Instrumentation::ResqueClient)
|
113
102
|
end
|
114
103
|
|
115
104
|
if ::Instana.config[:'resque-worker'][:enabled]
|
116
105
|
::Instana.logger.debug 'Instrumenting Resque Worker'
|
117
106
|
|
118
|
-
::
|
119
|
-
::
|
107
|
+
::Resque::Worker.prepend(::Instana::Instrumentation::ResqueWorker)
|
108
|
+
::Resque::Job.prepend(::Instana::Instrumentation::ResqueJob)
|
120
109
|
|
121
110
|
::Resque.before_fork do |job|
|
122
111
|
::Instana.agent.before_resque_fork
|
@@ -1,34 +1,24 @@
|
|
1
1
|
module Instana
|
2
2
|
module Instrumentation
|
3
3
|
module RestClientRequest
|
4
|
-
def
|
5
|
-
if klass.method_defined?(:execute)
|
6
|
-
klass.class_eval do
|
7
|
-
alias execute_without_instana execute
|
8
|
-
alias execute execute_with_instana
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def execute_with_instana & block
|
4
|
+
def execute(&block)
|
14
5
|
# Since RestClient uses net/http under the covers, we just
|
15
6
|
# provide span visibility here. HTTP related KVs are reported
|
16
7
|
# in the Net::HTTP instrumentation
|
17
8
|
::Instana.tracer.log_entry(:'rest-client')
|
18
9
|
|
19
|
-
|
10
|
+
super(&block)
|
20
11
|
rescue => e
|
21
12
|
::Instana.tracer.log_error(e)
|
22
13
|
raise
|
23
14
|
ensure
|
24
15
|
::Instana.tracer.log_exit(:'rest-client')
|
25
16
|
end
|
26
|
-
|
27
17
|
end
|
28
18
|
end
|
29
19
|
end
|
30
20
|
|
31
21
|
if defined?(::RestClient::Request) && ::Instana.config[:'rest-client'][:enabled]
|
32
22
|
::Instana.logger.debug "Instrumenting RestClient"
|
33
|
-
::RestClient::Request.send(:
|
23
|
+
::RestClient::Request.send(:prepend, ::Instana::Instrumentation::RestClientRequest)
|
34
24
|
end
|
data/lib/instana/secrets.rb
CHANGED
@@ -2,25 +2,25 @@ require 'uri'
|
|
2
2
|
require 'cgi'
|
3
3
|
|
4
4
|
module Instana
|
5
|
-
class Secrets
|
5
|
+
class Secrets
|
6
6
|
def remove_from_query(str, secret_values = Instana.agent.secret_values)
|
7
7
|
return str unless secret_values
|
8
|
-
|
8
|
+
|
9
9
|
url = URI(str)
|
10
|
-
params = CGI.parse(url.query)
|
11
|
-
|
10
|
+
params = CGI.parse(url.query || '')
|
11
|
+
|
12
12
|
redacted = params.map do |k, v|
|
13
13
|
needs_redaction = secret_values['list']
|
14
14
|
.any? { |t| matcher(secret_values['matcher']).(t,k) }
|
15
15
|
[k, needs_redaction ? '<redacted>' : v]
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
url.query = URI.encode_www_form(redacted)
|
19
19
|
CGI.unescape(url.to_s)
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
private
|
23
|
-
|
23
|
+
|
24
24
|
def matcher(name)
|
25
25
|
case name
|
26
26
|
when 'equals-ignore-case'
|
data/lib/instana/util.rb
CHANGED
@@ -2,46 +2,6 @@ module Instana
|
|
2
2
|
module Util
|
3
3
|
class << self
|
4
4
|
ID_RANGE = -2**63..2**63-1
|
5
|
-
|
6
|
-
# An agnostic approach to method aliasing.
|
7
|
-
#
|
8
|
-
# @param klass [Object] The class or module that holds the method to be alias'd.
|
9
|
-
# @param method [Symbol] The name of the method to be aliased.
|
10
|
-
#
|
11
|
-
def method_alias(klass, method)
|
12
|
-
if klass.method_defined?(method.to_sym) ||
|
13
|
-
klass.private_method_defined?(method.to_sym)
|
14
|
-
|
15
|
-
with = "#{method}_with_instana"
|
16
|
-
without = "#{method}_without_instana"
|
17
|
-
|
18
|
-
klass.class_eval do
|
19
|
-
alias_method without, method.to_s
|
20
|
-
alias_method method.to_s, with
|
21
|
-
end
|
22
|
-
else
|
23
|
-
::Instana.logger.debug "No such method (#{method}) to alias on #{klass}"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Calls on target_class to 'extend' cls
|
28
|
-
#
|
29
|
-
# @param target_cls [Object] the class/module to do the 'extending'
|
30
|
-
# @param cls [Object] the class/module to be 'extended'
|
31
|
-
#
|
32
|
-
def send_extend(target_cls, cls)
|
33
|
-
target_cls.send(:extend, cls) if defined?(target_cls)
|
34
|
-
end
|
35
|
-
|
36
|
-
# Calls on <target_cls> to include <cls> into itself.
|
37
|
-
#
|
38
|
-
# @param target_cls [Object] the class/module to do the 'including'
|
39
|
-
# @param cls [Object] the class/module to be 'included'
|
40
|
-
#
|
41
|
-
def send_include(target_cls, cls)
|
42
|
-
target_cls.send(:include, cls) if defined?(target_cls)
|
43
|
-
end
|
44
|
-
|
45
5
|
# Debugging helper method
|
46
6
|
#
|
47
7
|
def pry!
|
@@ -246,7 +206,7 @@ module Instana
|
|
246
206
|
#
|
247
207
|
def id_to_header(id)
|
248
208
|
return '' unless id.is_a?(String)
|
249
|
-
# Only send 64bit IDs downstream for now
|
209
|
+
# Only send 64bit IDs downstream for now
|
250
210
|
id.length == 32 ? id[16..-1] : id
|
251
211
|
end
|
252
212
|
|
data/lib/instana/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -68,17 +68,11 @@ def clear_all!
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def disable_redis_instrumentation
|
71
|
-
::
|
72
|
-
alias call call_without_instana
|
73
|
-
alias call_pipeline call_pipeline_without_instana
|
74
|
-
end
|
71
|
+
::Instana.config[:redis][:enabled] = false
|
75
72
|
end
|
76
73
|
|
77
74
|
def enable_redis_instrumentation
|
78
|
-
::
|
79
|
-
alias call call_with_instana
|
80
|
-
alias call_pipeline call_pipeline_with_instana
|
81
|
-
end
|
75
|
+
::Instana.config[:redis][:enabled] = true
|
82
76
|
end
|
83
77
|
|
84
78
|
def validate_sdk_span(json_span, sdk_hash = {}, errored = false, ec = 1)
|
@@ -156,4 +150,4 @@ def find_first_span_by_qualifier(spans, &block)
|
|
156
150
|
end
|
157
151
|
end
|
158
152
|
raise Exception.new("Span with qualifier not found")
|
159
|
-
end
|
153
|
+
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.2
|
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-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|