sqreen 1.14.0-java → 1.14.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sqreen/metrics/base.rb +1 -1
- data/lib/sqreen/metrics/binning.rb +11 -22
- data/lib/sqreen/metrics_store.rb +4 -1
- data/lib/sqreen/performance_notifications/binned_metrics.rb +26 -10
- data/lib/sqreen/runner.rb +7 -6
- data/lib/sqreen/version.rb +1 -1
- 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: 625e0b54a85e128be8a54aa94d91ff58d2dd99556fb6cfc79e22511731082fd3
|
4
|
+
data.tar.gz: 19ef99856cdc8269acf7888c424f2f80fdea4643b3c7deef4fa963f1de127923
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbe599eea8b8f74ced0183e8ec6a2de5bc5cfd9506618fb21e5b526cca2611ed77cf94765abd39c8f136584c9f88fd7747f3ac29bd0729b57c9f5e647a7dfba1
|
7
|
+
data.tar.gz: 510eaa669c74a5989023b4b08da5158dd97e0e65e847301510e0c2e457e674b4b360c80a2996708aef37b05dd04fc5a56013278cc1003ed9c6f4e6fcf6acba5f
|
data/lib/sqreen/metrics/base.rb
CHANGED
@@ -6,14 +6,18 @@ require 'sqreen/metrics/base'
|
|
6
6
|
module Sqreen
|
7
7
|
module Metric
|
8
8
|
# Takes numbers as samples and bins them (effectively, rounds them).
|
9
|
+
# Also collect max values
|
9
10
|
class Binning < Base
|
11
|
+
BASE_KEY = 'base'.freeze
|
12
|
+
FACTOR_KEY = 'factor'.freeze
|
10
13
|
# upper bound of i-th bin is factor * base^(i-1)
|
11
|
-
def initialize(
|
12
|
-
|
13
|
-
@base =
|
14
|
-
@factor =
|
15
|
-
|
16
|
-
|
14
|
+
def initialize(opts={})
|
15
|
+
options = opts.dup
|
16
|
+
@base = options.delete(BASE_KEY)
|
17
|
+
@factor = options.delete(FACTOR_KEY)
|
18
|
+
super(options)
|
19
|
+
log_base = Math.log(@base)
|
20
|
+
log_factor = Math.log(@factor)
|
17
21
|
@inv_log_base = 1 / log_base
|
18
22
|
@add_parcel = - log_factor / log_base
|
19
23
|
new_sample(Time.now.utc)
|
@@ -23,6 +27,7 @@ module Sqreen
|
|
23
27
|
h = @sample[OBSERVATION_KEY]
|
24
28
|
bin = bin_no(x)
|
25
29
|
h[bin] += 1
|
30
|
+
h['max'] = x if x > h['max']
|
26
31
|
end
|
27
32
|
|
28
33
|
def next_sample(time)
|
@@ -54,21 +59,5 @@ module Sqreen
|
|
54
59
|
res < 1 ? 1 : res
|
55
60
|
end
|
56
61
|
end
|
57
|
-
|
58
|
-
# overrides the constructor
|
59
|
-
class ParameterizedBinning < Binning
|
60
|
-
def initialize
|
61
|
-
raise 'Not configured' unless self.class.base && self.class.factor
|
62
|
-
super(self.class.base, self.class.factor)
|
63
|
-
end
|
64
|
-
|
65
|
-
class << self
|
66
|
-
attr_reader :base, :factor
|
67
|
-
def parameters(opts)
|
68
|
-
@base = opts[:base]
|
69
|
-
@factor = opts[:factor]
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
62
|
end
|
74
63
|
end
|
data/lib/sqreen/metrics_store.rb
CHANGED
@@ -20,6 +20,7 @@ module Sqreen
|
|
20
20
|
NAME_KEY = 'name'.freeze
|
21
21
|
KIND_KEY = 'kind'.freeze
|
22
22
|
PERIOD_KEY = 'period'.freeze
|
23
|
+
OPTIONS_KEY = 'options'.freeze
|
23
24
|
|
24
25
|
# Currently ready samples
|
25
26
|
attr_reader :store
|
@@ -38,7 +39,9 @@ module Sqreen
|
|
38
39
|
name = definition[NAME_KEY]
|
39
40
|
kind = definition[KIND_KEY]
|
40
41
|
klass = valid_metric(kind, name)
|
41
|
-
|
42
|
+
|
43
|
+
opts = definition[OPTIONS_KEY]
|
44
|
+
metric = mklass || klass.new(opts)
|
42
45
|
@metrics[name] = [
|
43
46
|
metric,
|
44
47
|
definition[PERIOD_KEY],
|
@@ -8,26 +8,36 @@ module Sqreen
|
|
8
8
|
module PerformanceNotifications
|
9
9
|
# Logs callback performance
|
10
10
|
class BinnedMetrics
|
11
|
+
DEFAULT_PERF_BASE = 2.0
|
12
|
+
DEFAULT_PERF_UNIT = 0.1 # ms
|
13
|
+
DEFAULT_PERF_PCT_BASE = 1.3
|
14
|
+
DEFAULT_PERF_PCT_UNIT = 1.0 # %
|
11
15
|
EVENT_REQ = 'req'.freeze # request total time
|
12
16
|
EVENT_TOTAL_TIME = 'sq'.freeze # sqreen total overhead callback time
|
17
|
+
EVENT_PERCENT = 'pct'.freeze # sqreen total overhead percent of time
|
13
18
|
|
14
19
|
EVT_NAME_REGEXP = %r{\ACallbacks/([^/]+)/([^/]+)\z}
|
15
20
|
|
16
21
|
# @param metrics_store [Sqreen::MetricsStore]
|
17
|
-
def initialize(metrics_store, period)
|
22
|
+
def initialize(metrics_store, period, perf_metric_opts, perf_metric_percent_opts)
|
18
23
|
@metrics_store = metrics_store
|
19
24
|
@period = period
|
20
25
|
@subid = nil
|
26
|
+
@perf_metric_opts = perf_metric_opts
|
27
|
+
@perf_metric_percent_opts = perf_metric_percent_opts
|
21
28
|
end
|
22
29
|
|
23
30
|
def enable
|
24
31
|
return unless @subid.nil?
|
25
32
|
|
26
33
|
metrics_store.create_metric(
|
27
|
-
'name' => EVENT_REQ, 'period' => period, 'kind' => '
|
34
|
+
'name' => EVENT_REQ, 'period' => period, 'kind' => 'Binning', 'options' => @perf_metric_opts
|
28
35
|
)
|
29
36
|
metrics_store.create_metric(
|
30
|
-
'name' => EVENT_TOTAL_TIME, 'period' => period, 'kind' => '
|
37
|
+
'name' => EVENT_TOTAL_TIME, 'period' => period, 'kind' => 'Binning', 'options' => @perf_metric_opts
|
38
|
+
)
|
39
|
+
metrics_store.create_metric(
|
40
|
+
'name' => EVENT_PERCENT, 'period' => period, 'kind' => 'Binning', 'options' => @perf_metric_percent_opts
|
31
41
|
)
|
32
42
|
|
33
43
|
@subid = Sqreen::PerformanceNotifications.subscribe(&method(:log))
|
@@ -67,9 +77,15 @@ module Sqreen
|
|
67
77
|
Sqreen.observations_queue.push(
|
68
78
|
[EVENT_REQ, nil, duration_millis, finish_time_obj]
|
69
79
|
)
|
80
|
+
total_t = SharedStorage[:sqreen_request_time]
|
70
81
|
Sqreen.observations_queue.push(
|
71
82
|
[EVENT_TOTAL_TIME, nil,
|
72
|
-
|
83
|
+
total_t, finish_time_obj]
|
84
|
+
)
|
85
|
+
return if !duration_millis or total_t >= duration_millis
|
86
|
+
Sqreen.observations_queue.push(
|
87
|
+
[EVENT_PERCENT, nil,
|
88
|
+
(total_t*100.0)/(duration_millis-total_t), finish_time_obj]
|
73
89
|
)
|
74
90
|
end
|
75
91
|
|
@@ -82,7 +98,7 @@ module Sqreen
|
|
82
98
|
def ensure_metric(metric_name)
|
83
99
|
return if metrics_store.metric?(metric_name)
|
84
100
|
metrics_store.create_metric(
|
85
|
-
'name' => metric_name, 'period' => period, 'kind' => '
|
101
|
+
'name' => metric_name, 'period' => period, 'kind' => 'Binning', 'options' => @perf_metric_opts
|
86
102
|
)
|
87
103
|
end
|
88
104
|
|
@@ -90,12 +106,12 @@ module Sqreen
|
|
90
106
|
class << self
|
91
107
|
# @return [Sqreen::PerformanceNotifications::BinnedMetrics]
|
92
108
|
attr_reader :instance
|
93
|
-
def enable(metrics_store, period = 60, base =
|
109
|
+
def enable(metrics_store, period = 60, base = DEFAULT_PERF_BASE, factor = DEFAULT_PERF_UNIT, base_pct = DEFAULT_PERF_PCT_BASE, factor_pct = DEFAULT_PERF_PCT_UNIT)
|
94
110
|
disable
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
111
|
+
@instance = new(metrics_store, period,
|
112
|
+
{'base'=> base, 'factor' => factor},
|
113
|
+
{'base' => base_pct, 'factor' => factor_pct}
|
114
|
+
).tap(&:enable)
|
99
115
|
end
|
100
116
|
|
101
117
|
def disable
|
data/lib/sqreen/runner.rb
CHANGED
@@ -33,8 +33,6 @@ module Sqreen
|
|
33
33
|
|
34
34
|
PERF_METRICS_PERIOD = 60 # 1 min
|
35
35
|
DEFAULT_PERF_LEVEL = 0 # disabled
|
36
|
-
DEFAULT_PERF_UNIT = 0.1 # ms
|
37
|
-
DEFAULT_PERF_BASE = 2.0
|
38
36
|
|
39
37
|
class << self
|
40
38
|
attr_reader :features
|
@@ -213,7 +211,7 @@ module Sqreen
|
|
213
211
|
end
|
214
212
|
end
|
215
213
|
|
216
|
-
def config_binned_metrics(level, base, factor)
|
214
|
+
def config_binned_metrics(level, base, factor, base_pct, factor_pct)
|
217
215
|
level = level.to_i
|
218
216
|
if level <= 0
|
219
217
|
Sqreen.log.debug('Disabling binned metrics')
|
@@ -221,7 +219,7 @@ module Sqreen
|
|
221
219
|
else
|
222
220
|
Sqreen.log.warn("Unknown value for perf_level: #{level}. Treating as 1") unless level == 1
|
223
221
|
PerformanceNotifications::BinnedMetrics.enable(
|
224
|
-
metrics_engine, PERF_METRICS_PERIOD, base.to_f, factor.to_f
|
222
|
+
metrics_engine, PERF_METRICS_PERIOD, base.to_f, factor.to_f, base_pct.to_f, factor_pct.to_f
|
225
223
|
)
|
226
224
|
end
|
227
225
|
end
|
@@ -306,8 +304,11 @@ module Sqreen
|
|
306
304
|
session.request_compression = features['request_compression'] if session
|
307
305
|
self.performance_metrics_period = features['performance_metrics_period']
|
308
306
|
config_binned_metrics(features['perf_level'] || DEFAULT_PERF_LEVEL,
|
309
|
-
features['perf_base'] || DEFAULT_PERF_BASE,
|
310
|
-
features['perf_unit'] || DEFAULT_PERF_UNIT
|
307
|
+
features['perf_base'] || PerformanceNotifications::BinnedMetrics::DEFAULT_PERF_BASE,
|
308
|
+
features['perf_unit'] || PerformanceNotifications::BinnedMetrics::DEFAULT_PERF_UNIT,
|
309
|
+
features['perf_pct_base'] || PerformanceNotifications::BinnedMetrics::DEFAULT_PERF_PCT_BASE,
|
310
|
+
features['perf_pct_unit'] || PerformanceNotifications::BinnedMetrics::DEFAULT_PERF_PCT_UNIT,
|
311
|
+
)
|
311
312
|
self.call_counts_metrics_period = features['call_counts_metrics_period']
|
312
313
|
hd = features['heartbeat_delay'].to_i
|
313
314
|
self.heartbeat_delay = hd if hd > 0
|
data/lib/sqreen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqreen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.14.
|
4
|
+
version: 1.14.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Sqreen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|