sqreen 1.21.0.beta3-java → 1.21.0-java
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/CHANGELOG.md +28 -15
- data/lib/sqreen/condition_evaluator.rb +5 -6
- data/lib/sqreen/conditionable.rb +6 -24
- data/lib/sqreen/ecosystem.rb +29 -2
- data/lib/sqreen/ecosystem/databases/database_connection_data.rb +23 -0
- data/lib/sqreen/ecosystem/databases/mongo.rb +39 -0
- data/lib/sqreen/ecosystem/databases/mysql.rb +54 -0
- data/lib/sqreen/ecosystem/databases/postgres.rb +51 -0
- data/lib/sqreen/ecosystem/databases/redis.rb +36 -0
- data/lib/sqreen/ecosystem/exception_reporting.rb +4 -2
- data/lib/sqreen/ecosystem/messaging/bunny.rb +61 -0
- data/lib/sqreen/ecosystem/messaging/kafka.rb +70 -0
- data/lib/sqreen/ecosystem/messaging/kinesis.rb +66 -0
- data/lib/sqreen/ecosystem/messaging/sqs.rb +68 -0
- data/lib/sqreen/ecosystem/module_api/message_producer.rb +9 -3
- data/lib/sqreen/ecosystem/module_api/tracing/consumer_data.rb +13 -0
- data/lib/sqreen/ecosystem/module_api/tracing/messaging_data.rb +35 -0
- data/lib/sqreen/ecosystem/module_api/tracing/producer_data.rb +13 -0
- data/lib/sqreen/ecosystem/module_registry.rb +5 -1
- data/lib/sqreen/ecosystem/tracing/modules/client.rb +7 -3
- data/lib/sqreen/ecosystem/tracing/modules/consumer.rb +35 -0
- data/lib/sqreen/ecosystem/tracing/modules/determine_ip.rb +28 -0
- data/lib/sqreen/ecosystem/tracing/modules/producer.rb +35 -0
- data/lib/sqreen/ecosystem/tracing/signals/tracing_consumer.rb +56 -0
- data/lib/sqreen/ecosystem/tracing/signals/tracing_producer.rb +56 -0
- data/lib/sqreen/ecosystem_integration.rb +1 -7
- data/lib/sqreen/ecosystem_integration/around_callbacks.rb +10 -20
- data/lib/sqreen/ecosystem_integration/instrumentation_service.rb +4 -8
- data/lib/sqreen/graft/call.rb +1 -21
- data/lib/sqreen/graft/hook.rb +75 -83
- data/lib/sqreen/kit/signals/specialized/sqreen_exception.rb +2 -0
- data/lib/sqreen/metrics.rb +0 -1
- data/lib/sqreen/rules/custom_error_cb.rb +1 -1
- data/lib/sqreen/rules/rule_cb.rb +2 -2
- data/lib/sqreen/runner.rb +12 -27
- data/lib/sqreen/version.rb +1 -1
- data/lib/sqreen/weave/budget.rb +14 -3
- data/lib/sqreen/weave/legacy/instrumentation.rb +94 -145
- metadata +22 -9
- data/lib/sqreen/ecosystem/redis/redis_connection.rb +0 -43
- data/lib/sqreen/metrics/req_detailed.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d55430d1415f21ee90558cf45a461137b79b06a4
|
4
|
+
data.tar.gz: 159b44e8ec7cd0c1409033a51121fa53166bbf4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1927c86d04f84f532666a40d785d4ad8cdb7c411b17d3bd07e98e3423f9bae2ed7fe83a713ef9a6b9866021067016336d7550324006ddd59800c38939f5967c
|
7
|
+
data.tar.gz: 997507ff2042ffebf01b1820d08f3d6fb8458ef3a63c086e66a3f46d009a901537cd0e26a974c01365213bef26a22138d624b79e2d573cd12e0168ad3fcea885
|
data/CHANGELOG.md
CHANGED
@@ -1,18 +1,31 @@
|
|
1
|
-
## 1.21.0
|
2
|
-
|
3
|
-
*
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
* Fix
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
## 1.21.0
|
2
|
+
|
3
|
+
* Add support for transport and tracing facilities
|
4
|
+
|
5
|
+
## 1.20.4
|
6
|
+
|
7
|
+
* Fix missing budget check
|
8
|
+
* Improve performance
|
9
|
+
* Align internal setting name for WAF
|
10
|
+
* Include response information in all payloads
|
11
|
+
* Improve robustness against invalid Unicode
|
12
|
+
* Prevent rule execution to pursue in early block cases
|
13
|
+
|
14
|
+
## 1.20.4.beta1
|
15
|
+
|
16
|
+
* Add optional dynamic time budget
|
17
|
+
* Add advanced per request metrics
|
18
|
+
* Improve robustness against exception in instrumentation
|
19
|
+
* Improve metric engine thread safety
|
20
|
+
* Restrict deferred logger to final logger severity on agent boot
|
21
|
+
|
22
|
+
## 1.20.3
|
23
|
+
|
24
|
+
* Fix signature check
|
25
|
+
|
26
|
+
## 1.20.2
|
27
|
+
|
28
|
+
* Fix performance regression in instrumentation engine
|
16
29
|
|
17
30
|
## 1.20.1
|
18
31
|
|
@@ -81,12 +81,11 @@ module Sqreen
|
|
81
81
|
if hkey.respond_to?(:empty?) && hkey.empty?
|
82
82
|
false
|
83
83
|
else
|
84
|
-
key_incl =
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
84
|
+
key_incl = if values.is_a?(String)
|
85
|
+
str_include?(values, hkey.to_s)
|
86
|
+
else
|
87
|
+
values.include?(hkey.to_s)
|
88
|
+
end
|
90
89
|
|
91
90
|
key_incl || hash_key_include?(values, hval, min_value_size, rem - 1)
|
92
91
|
end
|
data/lib/sqreen/conditionable.rb
CHANGED
@@ -28,39 +28,21 @@ module Sqreen
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def pre_with_conditions(inst, args, budget = nil, &block)
|
31
|
-
return pre_without_conditions(inst, args, budget, &block) if pre_conditions.nil?
|
32
|
-
|
33
31
|
eargs = [nil, framework, inst, args, @data, nil]
|
34
|
-
return nil
|
35
|
-
|
36
|
-
res = pre_without_conditions(inst, args, budget, &block)
|
37
|
-
return { passed_conditions: true } unless res.is_a?(Hash)
|
38
|
-
res[:passed_conditions] = true
|
39
|
-
res
|
32
|
+
return nil if !pre_conditions.nil? && !pre_conditions.evaluate(*eargs)
|
33
|
+
pre_without_conditions(inst, args, budget, &block)
|
40
34
|
end
|
41
35
|
|
42
36
|
def post_with_conditions(rv, inst, args, budget = nil, &block)
|
43
|
-
return post_without_conditions(rv, inst, args, budget, &block) if post_conditions.nil?
|
44
|
-
|
45
37
|
eargs = [nil, framework, inst, args, @data, rv]
|
46
|
-
return nil
|
47
|
-
|
48
|
-
res = post_without_conditions(rv, inst, args, budget, &block)
|
49
|
-
return { passed_conditions: true } if res.nil?
|
50
|
-
res[:passed_conditions] = true
|
51
|
-
res
|
38
|
+
return nil if !post_conditions.nil? && !post_conditions.evaluate(*eargs)
|
39
|
+
post_without_conditions(rv, inst, args, budget, &block)
|
52
40
|
end
|
53
41
|
|
54
42
|
def failing_with_conditions(rv, inst, args, budget = nil, &block)
|
55
|
-
return failing_without_conditions(rv, inst, args, budget, &block) if failing_conditions.nil?
|
56
|
-
|
57
43
|
eargs = [nil, framework, inst, args, @data, rv]
|
58
|
-
return nil
|
59
|
-
|
60
|
-
res = failing_without_conditions(rv, inst, args, budget, &block)
|
61
|
-
return { passed_conditions: true } if res.nil?
|
62
|
-
res[:passed_conditions] = true
|
63
|
-
res
|
44
|
+
return nil if !failing_conditions.nil? && !failing_conditions.evaluate(*eargs)
|
45
|
+
failing_without_conditions(rv, inst, args, budget, &block)
|
64
46
|
end
|
65
47
|
|
66
48
|
protected
|
data/lib/sqreen/ecosystem.rb
CHANGED
@@ -78,14 +78,41 @@ module Sqreen
|
|
78
78
|
require_relative 'ecosystem/http/net_http'
|
79
79
|
register Http::NetHttp.new
|
80
80
|
|
81
|
-
require_relative 'ecosystem/
|
82
|
-
register
|
81
|
+
require_relative 'ecosystem/databases/postgres'
|
82
|
+
register Databases::Postgres.new
|
83
|
+
|
84
|
+
require_relative 'ecosystem/databases/mysql'
|
85
|
+
register Databases::Mysql.new
|
86
|
+
|
87
|
+
require_relative 'ecosystem/databases/mongo'
|
88
|
+
register Databases::Mongo.new
|
89
|
+
|
90
|
+
require_relative 'ecosystem/databases/redis'
|
91
|
+
register Databases::Redis.new
|
92
|
+
|
93
|
+
require_relative 'ecosystem/messaging/sqs'
|
94
|
+
register Messaging::Sqs.new
|
95
|
+
|
96
|
+
require_relative 'ecosystem/messaging/kinesis'
|
97
|
+
register Messaging::Kinesis.new
|
98
|
+
|
99
|
+
require_relative 'ecosystem/messaging/bunny'
|
100
|
+
register Messaging::Bunny.new
|
101
|
+
|
102
|
+
require_relative 'ecosystem/messaging/kafka'
|
103
|
+
register Messaging::Kafka.new
|
83
104
|
|
84
105
|
require_relative 'ecosystem/tracing/modules/client'
|
85
106
|
register Tracing::Modules::Client.new
|
86
107
|
|
87
108
|
require_relative 'ecosystem/tracing/modules/server'
|
88
109
|
register Tracing::Modules::Server.new
|
110
|
+
|
111
|
+
require_relative 'ecosystem/tracing/modules/producer'
|
112
|
+
register Tracing::Modules::Producer.new
|
113
|
+
|
114
|
+
require_relative 'ecosystem/tracing/modules/consumer'
|
115
|
+
register Tracing::Modules::Consumer.new
|
89
116
|
end
|
90
117
|
|
91
118
|
def register(mod)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'sqreen/ecosystem/module_api/tracing/client_data'
|
2
|
+
|
3
|
+
module Sqreen
|
4
|
+
module Ecosystem
|
5
|
+
module Databases
|
6
|
+
class DatabaseConnectionData
|
7
|
+
include ModuleApi::Tracing::ClientData
|
8
|
+
|
9
|
+
# @return [Integer]
|
10
|
+
attr_accessor :port
|
11
|
+
|
12
|
+
# @return [String]
|
13
|
+
attr_accessor :unix_socket
|
14
|
+
|
15
|
+
# @return [String]
|
16
|
+
attr_accessor :username
|
17
|
+
|
18
|
+
# @return [String]
|
19
|
+
attr_accessor :db
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'sqreen/ecosystem/module_api'
|
2
|
+
require 'sqreen/ecosystem/module_api/instrumentation'
|
3
|
+
require 'sqreen/ecosystem/module_api/message_producer'
|
4
|
+
require 'sqreen/ecosystem/databases/database_connection_data'
|
5
|
+
|
6
|
+
module Sqreen
|
7
|
+
module Ecosystem
|
8
|
+
module Databases
|
9
|
+
class Mongo
|
10
|
+
include ModuleApi::Instrumentation
|
11
|
+
include ModuleApi::MessageProducer
|
12
|
+
|
13
|
+
def setup
|
14
|
+
advice = wrap_for_interest(DatabaseConnectionData, &method(:after_advice))
|
15
|
+
instrument 'Mongo::Client#initialize', after: advice
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# @param [Sqreen::Graft::CallbackCall] call
|
21
|
+
def after_advice(call, _ball)
|
22
|
+
return if call.raised
|
23
|
+
|
24
|
+
client = call.instance
|
25
|
+
server_addrs = client.cluster.servers.map(&:address)
|
26
|
+
|
27
|
+
server_addrs.map do |addr|
|
28
|
+
DatabaseConnectionData.new(
|
29
|
+
transport: :mongo,
|
30
|
+
host: addr.host,
|
31
|
+
port: addr.port,
|
32
|
+
db: client.database.name,
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'sqreen/ecosystem/module_api'
|
2
|
+
require 'sqreen/ecosystem/module_api/instrumentation'
|
3
|
+
require 'sqreen/ecosystem/module_api/message_producer'
|
4
|
+
require 'sqreen/ecosystem/module_api/tracing_id_generation'
|
5
|
+
require 'sqreen/ecosystem/module_api/tracing/client_data'
|
6
|
+
|
7
|
+
module Sqreen
|
8
|
+
module Ecosystem
|
9
|
+
module Databases
|
10
|
+
class Mysql
|
11
|
+
include ModuleApi::Instrumentation
|
12
|
+
include ModuleApi::MessageProducer
|
13
|
+
|
14
|
+
def setup
|
15
|
+
advice = wrap_for_interest(DatabaseConnectionData, &method(:after_advice))
|
16
|
+
instrument 'Mysql2::Client#connect', after: advice
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# instance is of type +Mysql2::Client+
|
22
|
+
# VALUE rb_mysql_connect(VALUE self, VALUE user, VALUE pass, VALUE host, VALUE port, VALUE database,
|
23
|
+
# VALUE socket, VALUE flags, VALUE conn_attrs) {
|
24
|
+
# @param [Sqreen::Graft::CallbackCall]
|
25
|
+
def after_advice(call, _ball)
|
26
|
+
args = call.args
|
27
|
+
|
28
|
+
# build & submit signal
|
29
|
+
signal = DatabaseConnectionData.new(transport: :mysql)
|
30
|
+
|
31
|
+
user = args[0]
|
32
|
+
host = args[2]
|
33
|
+
port = args[3]
|
34
|
+
db = args[4]
|
35
|
+
socket = args[5]
|
36
|
+
|
37
|
+
if socket && !socket.empty?
|
38
|
+
signal.unix_socket = socket
|
39
|
+
signal.host = 'localhost'
|
40
|
+
signal.ip = '::1'
|
41
|
+
else
|
42
|
+
signal.host = host
|
43
|
+
end
|
44
|
+
|
45
|
+
signal.port = port if port != 0
|
46
|
+
signal.username = user
|
47
|
+
signal.db = db
|
48
|
+
|
49
|
+
signal
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'sqreen/ecosystem/module_api'
|
2
|
+
require 'sqreen/ecosystem/module_api/instrumentation'
|
3
|
+
require 'sqreen/ecosystem/module_api/message_producer'
|
4
|
+
require 'sqreen/ecosystem/databases/database_connection_data'
|
5
|
+
|
6
|
+
module Sqreen
|
7
|
+
module Ecosystem
|
8
|
+
module Databases
|
9
|
+
class Postgres
|
10
|
+
include ModuleApi::Instrumentation
|
11
|
+
include ModuleApi::MessageProducer
|
12
|
+
|
13
|
+
def setup
|
14
|
+
advice = wrap_for_interest(DatabaseConnectionData, &method(:after_advice))
|
15
|
+
instrument 'PG::Connection#initialize', after: advice
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# instance is of type +PG::Connection+
|
21
|
+
# > c = PG::Connection.new(host: '172.17.0.2', password: 'mysecretpassword', user: 'postgres')
|
22
|
+
# => #<PG::Connection:0x000055b44d077d10>
|
23
|
+
# > %i{host port user db}.map { |m| c.send m }
|
24
|
+
# => ["172.17.0.2", 5432, "postgres", "postgres"]
|
25
|
+
def after_advice(call, _ball)
|
26
|
+
conn = call.instance
|
27
|
+
|
28
|
+
# build & submit signal
|
29
|
+
signal = DatabaseConnectionData.new(transport: :postgres)
|
30
|
+
|
31
|
+
host = conn.host
|
32
|
+
if host
|
33
|
+
if host.include?('/')
|
34
|
+
signal.unix_socket = host
|
35
|
+
signal.host = 'localhost'
|
36
|
+
signal.ip = '::1'
|
37
|
+
else
|
38
|
+
signal.host = host
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
signal.port = conn.port
|
43
|
+
signal.username = conn.user
|
44
|
+
signal.db = conn.db
|
45
|
+
|
46
|
+
signal
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'sqreen/ecosystem/module_api'
|
2
|
+
require 'sqreen/ecosystem/module_api/instrumentation'
|
3
|
+
require 'sqreen/ecosystem/module_api/message_producer'
|
4
|
+
require 'sqreen/ecosystem/databases/database_connection_data'
|
5
|
+
|
6
|
+
module Sqreen
|
7
|
+
module Ecosystem
|
8
|
+
module Databases
|
9
|
+
class Redis
|
10
|
+
include ModuleApi::Instrumentation
|
11
|
+
include ModuleApi::MessageProducer
|
12
|
+
|
13
|
+
def setup
|
14
|
+
advice = wrap_for_interest(DatabaseConnectionData, &method(:after_advice))
|
15
|
+
instrument 'Redis#initialize', after: advice
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# @param [Sqreen::Graft::CallbackCall] call
|
21
|
+
def after_advice(call, _ball)
|
22
|
+
return if call.raised
|
23
|
+
|
24
|
+
conn = call.instance.connection
|
25
|
+
|
26
|
+
DatabaseConnectionData.new(
|
27
|
+
transport: :redis,
|
28
|
+
host: conn[:host],
|
29
|
+
port: conn[:port],
|
30
|
+
db: conn[:db].to_s,
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'sqreen/ecosystem/dispatch_table'
|
2
2
|
require 'sqreen/ecosystem/loggable'
|
3
|
+
require 'sqreen/kit/configuration'
|
3
4
|
require 'sqreen/kit/signals/specialized/sqreen_exception'
|
4
5
|
|
5
6
|
module Sqreen
|
@@ -16,10 +17,11 @@ module Sqreen
|
|
16
17
|
logger.debug { e.backtrace.map { |x| " #{x}" }.join("\n") }
|
17
18
|
|
18
19
|
signal = Sqreen::Kit::Signals::Specialized::SqreenException.new(
|
19
|
-
ruby_exception: e
|
20
|
+
ruby_exception: e,
|
21
|
+
source: Sqreen::Kit::Configuration.default_source
|
20
22
|
)
|
21
23
|
|
22
|
-
DispatchTable.consume_signal
|
24
|
+
DispatchTable.consume_signal[signal]
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'sqreen/ecosystem/module_api'
|
2
|
+
require 'sqreen/ecosystem/module_api/instrumentation'
|
3
|
+
require 'sqreen/ecosystem/module_api/message_producer'
|
4
|
+
require 'sqreen/ecosystem/module_api/tracing/consumer_data'
|
5
|
+
require 'sqreen/ecosystem/module_api/tracing/producer_data'
|
6
|
+
|
7
|
+
module Sqreen
|
8
|
+
module Ecosystem
|
9
|
+
module Messaging
|
10
|
+
class Bunny
|
11
|
+
include ModuleApi::Loggable
|
12
|
+
include ModuleApi::Instrumentation
|
13
|
+
include ModuleApi::MessageProducer
|
14
|
+
|
15
|
+
def setup
|
16
|
+
advice_send = wrap_for_interest(ModuleApi::Tracing::ProducerData, &method(:after_send_advice))
|
17
|
+
advice_receive = wrap_for_interest(ModuleApi::Tracing::ConsumerData, &method(:after_receive_advice))
|
18
|
+
advice_receive_consumer = wrap_for_interest(ModuleApi::Tracing::ConsumerData, &method(:after_receive_advice_consumer))
|
19
|
+
instrument 'Bunny::Queue#publish', after: advice_send
|
20
|
+
instrument 'Bunny::Queue#pop', after: advice_receive
|
21
|
+
instrument 'Bunny::Consumer#call', after: advice_receive_consumer
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
# @param [Sqreen::Graft::CallbackCall] call
|
27
|
+
def after_send_advice(call, _ball)
|
28
|
+
return if call.raised
|
29
|
+
|
30
|
+
create_signal(call.instance, ModuleApi::Tracing::ProducerData)
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param [Sqreen::Graft::CallbackCall] call
|
34
|
+
def after_receive_advice(call, _ball)
|
35
|
+
return if call.raised
|
36
|
+
|
37
|
+
create_signal(call.instance, ModuleApi::Tracing::ConsumerData)
|
38
|
+
end
|
39
|
+
|
40
|
+
# @param [Sqreen::Graft::CallbackCall] call
|
41
|
+
def after_receive_advice_consumer(call, _ball)
|
42
|
+
return if call.raised
|
43
|
+
|
44
|
+
queue = call.instance.queue
|
45
|
+
create_signal(queue, ModuleApi::Tracing::ConsumerData)
|
46
|
+
end
|
47
|
+
|
48
|
+
# @param [Bunny::Queue] q
|
49
|
+
def create_signal(q, clazz)
|
50
|
+
conn = q.channel.connection
|
51
|
+
|
52
|
+
clazz.new(
|
53
|
+
message_type: :amqp,
|
54
|
+
host: conn.host,
|
55
|
+
topic: q.name,
|
56
|
+
)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|