sqreen 1.20.1 → 1.20.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7be645cedf514d1af5754fc7244738e17f817aad09761d2da7d7fa032ac55801
4
- data.tar.gz: f81295c9ac98714284d6368bc5e01c1a857317c8dad98d53366b24e53cc6cc47
3
+ metadata.gz: 20f83c83a19022c3bfba53af705716e2d4b4d791912bf32c6e7e2853496a4b05
4
+ data.tar.gz: 6592f5a6c88895016924c4a342d6c1f48f885527c18fc0b182495d2905cef926
5
5
  SHA512:
6
- metadata.gz: 986748fc2c11ee0a6ea7a997d661246d2840e170fdcbe5d7c1221fb189e3b6a9281e4feb1025f58f1ac6712ff10f598caa7d81867a7a62898138e743eadc9262
7
- data.tar.gz: 39b246ce351e780f539a0d2fe3df9791996d8203056545ab5472f0deec2e1526351bfc9cbb4f8c4cd5c145969db0b177b1b559a7491e4a8a15de4e9dd3721665
6
+ metadata.gz: 349fecb7524cb1740965162e596708fede99c5ab12bd5ed0a009c324e360585a15f2237c78614b666e77d5bbbf5b044a9a1ee7be8d3ce791b377cbc1ecbe15aa
7
+ data.tar.gz: ad4b8725a6531e80a4e47aac8c820f88284391a8f674ae59e8908846714c8b1c76be7fd95034cdf4885588f39e413308f39cc5688f6ed207558b48d0b14def5f
@@ -1,3 +1,7 @@
1
+ ## 1.20.2
2
+
3
+ * Fix performance regression in instrumentation engine
4
+
1
5
  ## 1.20.1
2
6
 
3
7
  * Add fallback mechanisms when connecting to new Sqreen backend API domains
@@ -1,2 +1 @@
1
- <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Sqreen has detected an attack.</title> <style>html, body, div, span, h1, a{margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline}body{background: -webkit-radial-gradient(26% 19%, circle, #fff, #f4f7f9); background: radial-gradient(circle at 26% 19%, #fff, #f4f7f9); display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -ms-flex-line-pack: center; align-content: center; width: 100%; min-height: 100vh; line-height: 1}svg, h1, p{display: block}svg{margin: 0 auto 4vh}h1{font-family: sans-serif; font-weight: 300; font-size: 34px; color: #384886; line-height: normal}p{font-size: 18px; line-height: normal; color: #b8bccc; font-family: sans-serif; font-weight: 300}a{color: #b8bccc}.flex{text-align: center}</style></head><body> <div class="flex"> <svg xmlns="http://www.w3.org/2000/svg" width="230" height="250" viewBox="0 0 230 250" enable-background="new 0 0 230 250"> <style>.st0{opacity: 0.4; filter: url(#a);}.st1{fill: #FFFFFF;}.st2{fill: #B0ACFF;}.st3{fill: #4842B7;}.st4{fill: #1E0936;}</style> <filter id="a" width="151.7%" height="146%" x="-25.8%" y="-16%" filterUnits="objectBoundingBox"> <feOffset dy="14" in="SourceAlpha" result="shadowOffsetOuter1"/> <feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="13"/> <feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0"/> </filter> <g class="st0"> <path id="b_2_" d="M202.6 34.9c-.2-1.2-.8-2.1-1.9-2.8-3.8-2-37.9-20.1-85.7-20.1-48.8 0-84.2 19.3-85.7 20.1-1 .6-1.6 1.6-1.8 2.7-14.8 123.2 84.7 176.3 85.7 176.8.6.3 1.2.4 1.8.4.6 0 1.2-.1 1.7-.4 1-.5 100.4-55 85.9-176.7z"/> </g> <path id="b_1_" d="M202.6 34.9c-.2-1.2-.8-2.1-1.9-2.8-3.8-2-37.9-20.1-85.7-20.1-48.8 0-84.2 19.3-85.7 20.1-1 .6-1.6 1.6-1.8 2.7-14.8 123.2 84.7 176.3 85.7 176.8.6.3 1.2.4 1.8.4.6 0 1.2-.1 1.7-.4 1-.5 100.4-55 85.9-176.7z" class="st1"/> <g id="nest-cmyk-indigo"> <ellipse id="sqreen" cx="115.5" cy="69.9" class="st2" rx="12.7" ry="12.7"/> <path id="app" d="M113.6 91.9V71.5L95.5 61.1v18l6.4-3.7c.5 1.1 1 2.2 1.7 3.2L97 82.3l16.6 9.6zm3.7 0l16.6-9.6-6.7-3.9c.7-1 1.3-2 1.7-3.2l6.4 3.7v-18l-18.1 10.5v20.5zM96.9 57.6l18.6 10.7L134 57.6 117.3 48v7.6c-.6-.1-1.2-.1-1.8-.1-.6 0-1.2 0-1.8.1V48l-16.8 9.6zm20.2-13.9l20.3 11.7c1 .6 1.6 1.7 1.6 2.8v23.5c0 1.2-.6 2.2-1.6 2.8l-20.3 11.7c-1 .6-2.3.6-3.3 0L93.5 84.5c-1-.6-1.6-1.7-1.6-2.8V58.2c0-1.2.6-2.2 1.6-2.8l20.3-11.7c1-.6 2.3-.6 3.3 0z" class="st3"/> </g> <path id="s" d="M74.6 113c-1.8-1-3.5-1.5-5.2-1.5-1.4 0-2.3.6-2.3 1.5 0 2.7 10.1.4 10.1 7.7 0 3.3-2.9 6-7.6 6-2.1 0-4.7-.5-6.4-1.4l-.1-.1c-.3-.2-.3-.5-.2-.8l1.2-2.7c.1-.3.5-.5.9-.3.1 0 .1.1.2.1 1.5.6 3.1 1 4.6 1 2.2 0 2.9-.6 2.9-1.7 0-3-10.1-.8-10.1-7.7 0-3.1 2.7-5.8 7-5.8 2.1 0 5 .7 6.9 1.8.1 0 .1.1.2.1.3.2.4.5.3.8l-1.2 2.7c-.1.3-.5.5-.9.3h-.3z" class="st4"/> <path id="q" d="M93.6 107.8h3.2c.4 0 .7.3.7.7v25.9c0 .4-.3.7-.7.7h-3.2c-.4 0-.7-.3-.7-.7v-9.1c-1.2.8-2.9 1.4-4.7 1.4-5.4 0-9.6-4.3-9.6-9.7 0-5.4 4.1-9.7 9.6-9.7 1.8 0 3.5.6 4.7 1.4v-.1c0-.5.3-.8.7-.8zm-.7 12.4v-6.5c-1.3-1.3-2.8-2.1-4.5-2.1-2.9 0-5.1 2.3-5.1 5.4s2.2 5.4 5.1 5.4c1.7-.1 3.2-.7 4.5-2.2z" class="st4"/> <path id="r" d="M112.5 107.8c-1-.4-2-.6-3-.6-1.8 0-3.5.6-4.9 1.4v-.2c0-.3-.2-.5-.5-.5h-3.4c-.3 0-.5.2-.5.5v17.8c0 .3.2.5.5.5h3.4c.3 0 .5-.2.5-.5v-12.6c1.1-1.2 2.8-1.9 4.6-1.9.4 0 .9 0 1.5.2.3.1.6-.1.7-.4l1.3-2.9c.1-.4 0-.7-.2-.8z" class="st4"/> <path id="e" d="M129 124.7c-1.7 1-4.2 2-6.7 2-6 0-10.3-4.4-10.3-9.9 0-5.3 3.7-9.6 9.4-9.6 5.2 0 8.4 4.4 8.4 9 0 .4 0 .9-.1 1.2 0 .3-.3.6-.7.6h-12.5c.5 2.8 2.8 4.5 5.8 4.5 1.7 0 3.4-.5 5.1-1.4.3-.2.6-.1.8.2l1.2 2.6c.1.2 0 .4-.2.6-.2.1-.2.2-.2.2zm-12.4-10h8.5c-.2-1.8-1.9-3.3-3.9-3.3-2.5-.1-4 1.4-4.6 3.3z" class="st4"/> <path id="e_1_" d="M148.7 124.7c-1.7 1-4.2 2-6.7 2-6 0-10.3-4.4-10.3-9.9 0-5.3 3.7-9.6 9.4-9.6 5.2 0 8.4 4.4 8.4 9 0 .4 0 .9-.1 1.2 0 .3-.3.6-.7.6h-12.5c.5 2.8 2.8 4.5 5.8 4.5 1.7 0 3.4-.5 5.1-1.4.3-.2.6-.1.8.2l1.2 2.6c.1.2 0 .4-.2.6-.2.1-.2.2-.2.2zm-12.4-10h8.5c-.2-1.8-1.9-3.3-3.9-3.3-2.5-.1-4 1.4-4.6 3.3z" class="st4"/> <path id="n" d="M151.5 108.5V126c0 .4.3.7.7.7h3.2c.4 0 .7-.3.7-.7v-12.5c1.1-1.2 2.8-1.9 4.6-1.9 2.9 0 4.5 1.6 4.5 4.7v9.7c0 .4.3.7.7.7h3.2c.4 0 .7-.3.7-.7v-10.2c0-5.2-2.9-8.5-8.8-8.5-1.8 0-3.5.6-4.9 1.4v-.1c0-.4-.3-.7-.7-.7h-3.2c-.4-.1-.7.2-.7.6z" class="st4"/> </svg> <h1>Uh Oh! Sqreen has detected an attack.</h1> <p>If you are the application owner, check the Sqreen <a href="https://my.sqreen.com/">dashboard</a> for more information.</p></div></body></html>
2
-
1
+ <!-- Sorry, you’ve been blocked --><!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>You've been blocked</title><style>a,body,div,h1,html,span{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}body{background:-webkit-radial-gradient(26% 19%,circle,#fff,#f4f7f9);background:radial-gradient(circle at 26% 19%,#fff,#f4f7f9);display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;width:100%;min-height:100vh;line-height:1;flex-direction:column}h1,p,svg{display:block}svg{margin:0 auto 4vh}main{text-align:center;flex:1;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;flex-direction:column}h1{font-family:sans-serif;font-weight:600;font-size:34px;color:#1e0936;line-height:1.2}p{font-size:18px;line-height:normal;color:#646464;font-family:sans-serif;font-weight:400}a{color:#4842b7}footer{width:100%;text-align:center}footer p{font-size:16px}</style></head><body><main><svg width="170px" height="193px" viewBox="0 0 170 193" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true"><g id="exports" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="Artboard" transform="translate(-186.000000, -189.000000)"><g id="logo-cmyk-indigo" transform="translate(186.000000, 189.000000)"><g id="nest-cmyk-indigo"><ellipse id="sqreen" fill="#B0ACFF" cx="85" cy="96.5" rx="45.7692308" ry="45.7966102"></ellipse><path d="M78.4615385,175.749389 L78.4615385,102.2092 L13.1398162,64.4731256 L13.1398162,129.181112 L36.352167,115.771438 C37.9764468,119.873152 40.1038639,123.720553 42.6582364,127.237412 L18.5723996,141.151695 L78.4615385,175.749389 Z M91.5384615,175.749389 L151.4276,141.151695 L127.341764,127.237412 C129.896136,123.720553 132.023553,119.873152 133.647833,115.771438 L156.860184,129.181112 L156.860184,64.4731256 L91.5384615,102.2092 L91.5384615,175.749389 Z M18.0061522,52.1754237 L85,90.8774777 L151.993848,52.1754237 L91.5384615,17.2506105 L91.5384615,44.565949 C89.3964992,44.2986903 87.2143177,44.1610169 85,44.1610169 C82.7856823,44.1610169 80.6035008,44.2986903 78.4615385,44.565949 L78.4615385,17.2506105 L18.0061522,52.1754237 Z M90.8846156,1.76392358 L164.052491,44.0326866 C167.693904,46.1363149 169.937107,50.0239804 169.937107,54.231237 L169.937107,138.768763 C169.937107,142.97602 167.693904,146.863685 164.052491,148.967313 L90.8846156,191.236076 C87.2432028,193.339705 82.7567972,193.339705 79.1153844,191.236076 L5.94750871,148.967313 C2.30609589,146.863685 0.0628930904,142.97602 0.0628930904,138.768763 L0.0628930904,54.231237 C0.0628930904,50.0239804 2.30609589,46.1363149 5.94750871,44.0326866 L79.1153844,1.76392358 C82.7567972,-0.339704735 87.2432028,-0.339704735 90.8846156,1.76392358 Z" id="app" fill="#4842B7"></path></g></g></g></g></svg><h1>Sorry, you've been blocked</h1><p>Contact the website owner</p></main><footer><p>Security provided by <a href="https://www.sqreen.com/?utm_medium=block_page" target="_blank">Sqreen</a></p></footer></body></html>
@@ -16,6 +16,10 @@ module Sqreen
16
16
  @logger = ::Logger.new(@buffer)
17
17
  end
18
18
 
19
+ def debug?
20
+ true
21
+ end
22
+
19
23
  def debug(msg = nil, &block)
20
24
  @logger.debug(msg, &block)
21
25
  end
@@ -98,53 +98,66 @@ module Sqreen
98
98
  Process.clock_gettime(Process::CLOCK_MONOTONIC)
99
99
  end
100
100
 
101
- attr_reader :tag
101
+ attr_reader :tag, :size, :duration
102
102
 
103
103
  def initialize(tag, &block)
104
104
  @tag = tag
105
- @blips = []
106
105
  @block = block
107
- end
108
-
109
- def duration
110
- @blips.each_with_index.reduce(0) { |a, (e, i)| i.even? ? a - e : a + e }
106
+ @duration = 0
107
+ @size = 0
111
108
  end
112
109
 
113
110
  def elapsed
114
- @blips.each_with_index.reduce(0) { |a, (e, i)| i.even? ? a - e : a + e } + Timer.read
111
+ @duration + Timer.read
115
112
  end
116
113
 
117
114
  def ignore
118
- @blips << Timer.read
115
+ @size += 1
116
+ @duration += Timer.read
119
117
  yield(self)
120
118
  ensure
121
- @blips << Timer.read
119
+ @size += 1
120
+ @duration -= Timer.read
122
121
  end
123
122
 
124
- def measure
125
- @blips << Timer.read
123
+ def measure(opts = nil)
124
+ now = Timer.read
125
+ ignore = opts[:ignore] if opts
126
+ if ignore
127
+ ignore.size += 1
128
+ ignore.duration += now
129
+ end
130
+ @size += 1
131
+ @duration -= now
126
132
  yield(self)
127
133
  ensure
128
- @blips << Timer.read
134
+ now = Timer.read
135
+ if ignore
136
+ ignore.size += 1
137
+ ignore.duration -= now
138
+ end
139
+ @size += 1
140
+ @duration += now
129
141
  @block.call(self) if @block
130
- Sqreen::Graft.logger.debug { "#{@tag}: time=%.03fus" % (duration * 1_000_000) }
131
142
  end
132
143
 
133
144
  def start
134
- @blips << Timer.read
145
+ @size += 1
146
+ @duration -= Timer.read
135
147
  end
136
148
 
137
149
  def stop
138
- @blips << Timer.read
139
- end
140
-
141
- def size
142
- @blips.size
150
+ @size += 1
151
+ @duration += Timer.read
143
152
  end
144
153
 
145
154
  def to_s
146
155
  "#{@tag}: time=%.03fus" % (duration * 1_000_000)
147
156
  end
157
+
158
+ protected
159
+
160
+ attr_writer :size, :duration
148
161
  end
149
162
  end
150
163
  end
@@ -21,7 +21,7 @@ module Sqreen
21
21
  end
22
22
 
23
23
  def call(*args, &block)
24
- Sqreen::Graft.logger.debug { "[#{Process.pid}] Callback #{@name} disabled:#{disabled?}" }
24
+ # Sqreen::Graft.logger.debug { "[#{Process.pid}] Callback #{@name} disabled:#{disabled?}" } if Sqreen::Graft.logger.debug?
25
25
  return if @disabled
26
26
  @block.call(*args, &block)
27
27
  end
@@ -46,27 +46,31 @@ module Sqreen
46
46
  end
47
47
 
48
48
  def before(tag = nil, opts = {}, &block)
49
- return @before.sort_by(&:rank) if block.nil?
49
+ return @before if block.nil?
50
50
 
51
51
  @before << Callback.new(callback_name(:before, tag), opts, &block)
52
+ @before.sort_by!(&:rank)
52
53
  end
53
54
 
54
55
  def after(tag = nil, opts = {}, &block)
55
- return @after.sort_by(&:rank) if block.nil?
56
+ return @after if block.nil?
56
57
 
57
58
  @after << Callback.new(callback_name(:after, tag), opts, &block)
59
+ @after.sort_by!(&:rank)
58
60
  end
59
61
 
60
62
  def raised(tag = nil, opts = {}, &block)
61
- return @raised.sort_by(&:rank) if block.nil?
63
+ return @raised if block.nil?
62
64
 
63
65
  @raised << Callback.new(callback_name(:raised, tag), opts, &block)
66
+ @raised.sort_by!(&:rank)
64
67
  end
65
68
 
66
69
  def ensured(tag = nil, opts = {}, &block)
67
- return @ensured.sort_by(&:rank) if block.nil?
70
+ return @ensured if block.nil?
68
71
 
69
72
  @ensured << Callback.new(callback_name(:ensured, tag), opts, &block)
73
+ @ensured.sort_by!(&:rank)
70
74
  end
71
75
 
72
76
  def depends_on(&block)
@@ -112,6 +116,13 @@ module Sqreen
112
116
  end
113
117
 
114
118
  def self.wrapper(hook)
119
+ timed_hooks_proc = proc do |t|
120
+ Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:timed_hooks] << t
121
+ end
122
+ timed_callbacks_proc = proc do |t|
123
+ Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:timed_callbacks] << t
124
+ end
125
+
115
126
  Proc.new do |*args, &block|
116
127
  if Thread.current[:sqreen_hook_entered] || Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:time_budget_expended]
117
128
  if hook.point.super?
@@ -121,10 +132,12 @@ module Sqreen
121
132
  end
122
133
  end
123
134
 
124
- Timer.new(hook.point) do |t|
125
- Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:timed_hooks] << t
126
- end.measure do |chrono|
127
- Sqreen::Graft.logger.debug { "[#{Process.pid}] Hook #{hook.point} disabled:#{hook.disabled?} caller:#{Kernel.caller[2].inspect}" }
135
+ hook_point_super = hook.point.super?
136
+ logger = Sqreen::Graft.logger
137
+ logger_debug = Sqreen::Graft.logger.debug?
138
+
139
+ Timer.new(hook.point, &timed_hooks_proc).measure do |chrono|
140
+ logger.debug { "[#{Process.pid}] Hook #{hook.point} disabled:#{hook.disabled?} caller:#{Kernel.caller[2].inspect}" } if logger_debug
128
141
 
129
142
  budget = Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:time_budget]
130
143
  timer = Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:timer] if budget
@@ -143,37 +156,29 @@ module Sqreen
143
156
  # TODO: TimedHookCall TimedCallbackCall
144
157
  # TODO: TimeBoundHookCall TimeBoundCallbackCall TimeBoundFlow?
145
158
 
146
- Timer.new("#{hook.point}@before") do |t|
147
- Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:timed_hooks_before] << t
148
- end.measure do |before_chrono|
149
- hook.before.each do |c|
150
- next if c.ignore && c.ignore.call
151
-
152
- if timer && !c.mandatory
153
- remaining = budget - timer.elapsed
154
- unless remaining > 0
155
- Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:skipped_callbacks] << c && Thread.current[:sqreen_http_request][:time_budget_expended] = true
156
- next
157
- end
159
+ hook.before.each do |c|
160
+ next if c.ignore && c.ignore.call
161
+
162
+ if timer && !c.mandatory
163
+ remaining = budget - timer.elapsed
164
+ unless remaining > 0
165
+ Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:skipped_callbacks] << c && Thread.current[:sqreen_http_request][:time_budget_expended] = true
166
+ next
158
167
  end
168
+ end
159
169
 
160
- flow = catch(Ball.new) do |ball|
161
- Timer.new(c.name) do |t|
162
- Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:timed_callbacks] << t
163
- end.measure do
164
- before_chrono.ignore do
165
- c.call(CallbackCall.new(c, remaining, hooked_call.instance, hooked_call.args_passed), ball)
166
- end
167
- end
170
+ flow = catch(Ball.new) do |ball|
171
+ Timer.new(c.name, &timed_callbacks_proc).measure(ignore: chrono) do
172
+ c.call(CallbackCall.new(c, remaining, hooked_call.instance, hooked_call.args_passed), ball)
168
173
  end
174
+ end
169
175
 
170
- next unless c.flow && flow.is_a?(Flow)
171
- hooked_call.raise = flow.raise and hooked_call.raising = true if flow.raise?
172
- hooked_call.args_pass = flow.args and hooked_call.args_passing = true if flow.args?
173
- hooked_call.return = flow.return and hooked_call.returning = true if flow.return?
174
- break if flow.break?
175
- end unless hook.disabled?
176
- end
176
+ next unless c.flow && flow.is_a?(Flow)
177
+ hooked_call.raise = flow.raise and hooked_call.raising = true if flow.raise?
178
+ hooked_call.args_pass = flow.args and hooked_call.args_passing = true if flow.args?
179
+ hooked_call.return = flow.return and hooked_call.returning = true if flow.return?
180
+ break if flow.break?
181
+ end unless hook.disabled?
177
182
 
178
183
  raise hooked_call.raise if hooked_call.raising
179
184
  return hooked_call.return if hooked_call.returning
@@ -184,7 +189,7 @@ module Sqreen
184
189
 
185
190
  begin
186
191
  chrono.ignore do
187
- if hook.point.super?
192
+ if hook_point_super
188
193
  hooked_call.returned = super(*(hooked_call.args_passing ? hooked_call.args_pass : hooked_call.args_passed), &block)
189
194
  else
190
195
  hooked_call.returned = hook.point.apply(hooked_call.instance, 'sqreen_hook', *(hooked_call.args_passing ? hooked_call.args_pass : hooked_call.args_passed), &block)
@@ -195,40 +200,32 @@ module Sqreen
195
200
  Thread.current[:sqreen_hook_entered] = true
196
201
  hooked_call.raised = e
197
202
 
198
- Sqreen::Graft.logger.debug { "[#{Process.pid}] Hook #{hook.point} disabled:#{hook.disabled?} exception:#{e}" }
203
+ logger.debug { "[#{Process.pid}] Hook #{hook.point} disabled:#{hook.disabled?} exception:#{e}" } if logger_debug
199
204
  raise if hook.raised.empty?
200
205
 
201
- Timer.new("#{hook.point}@raised") do |t|
202
- Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:timed_hooks_raised] << t
203
- end.measure do |raised_chrono|
204
- hook.raised.each do |c|
205
- next if c.ignore && c.ignore.call
206
-
207
- if timer && !c.mandatory
208
- remaining = budget - timer.elapsed
209
- unless remaining > 0
210
- Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:skipped_callbacks] << c && Thread.current[:sqreen_http_request][:time_budget_expended] = true
211
- next
212
- end
206
+ hook.raised.each do |c|
207
+ next if c.ignore && c.ignore.call
208
+
209
+ if timer && !c.mandatory
210
+ remaining = budget - timer.elapsed
211
+ unless remaining > 0
212
+ Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:skipped_callbacks] << c && Thread.current[:sqreen_http_request][:time_budget_expended] = true
213
+ next
213
214
  end
215
+ end
214
216
 
215
- flow = catch(Ball.new) do |ball|
216
- Timer.new(c.name) do |t|
217
- Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:timed_callbacks] << t
218
- end.measure do
219
- raised_chrono.ignore do
220
- c.call(CallbackCall.new(c, remaining, hooked_call.instance, hooked_call.args_passing ? hooked_call.args_pass : hooked_call.args_passed, hooked_call.raised), ball)
221
- end
222
- end
217
+ flow = catch(Ball.new) do |ball|
218
+ Timer.new(c.name, &timed_callbacks_proc).measure(ignore: chrono) do
219
+ c.call(CallbackCall.new(c, remaining, hooked_call.instance, hooked_call.args_passing ? hooked_call.args_pass : hooked_call.args_passed, hooked_call.raised), ball)
223
220
  end
221
+ end
224
222
 
225
- next unless c.flow && flow.is_a?(Flow)
226
- hooked_call.raise = flow.raise and hooked_call.raising = true if flow.raise?
227
- hooked_call.return = flow.return and hooked_call.returning = true if flow.return?
228
- hooked_call.retrying = true if flow.retry?
229
- break if flow.break?
230
- end unless hook.disabled?
231
- end
223
+ next unless c.flow && flow.is_a?(Flow)
224
+ hooked_call.raise = flow.raise and hooked_call.raising = true if flow.raise?
225
+ hooked_call.return = flow.return and hooked_call.returning = true if flow.return?
226
+ hooked_call.retrying = true if flow.retry?
227
+ break if flow.break?
228
+ end unless hook.disabled?
232
229
 
233
230
  retry if hooked_call.retrying
234
231
  raise hooked_call.raise if hooked_call.raising
@@ -238,72 +235,56 @@ module Sqreen
238
235
  timer.start if timer
239
236
  Thread.current[:sqreen_hook_entered] = true
240
237
 
241
- Timer.new("#{hook.point}@after") do |t|
242
- Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:timed_hooks_after] << t
243
- end.measure do |after_chrono|
244
- hook.after.each do |c|
245
- next if c.ignore && c.ignore.call
246
-
247
- if timer && !c.mandatory
248
- remaining = budget - timer.elapsed
249
- unless remaining > 0
250
- Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:skipped_callbacks] << c && Thread.current[:sqreen_http_request][:time_budget_expended] = true
251
- next
252
- end
238
+ hook.after.each do |c|
239
+ next if c.ignore && c.ignore.call
240
+
241
+ if timer && !c.mandatory
242
+ remaining = budget - timer.elapsed
243
+ unless remaining > 0
244
+ Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:skipped_callbacks] << c && Thread.current[:sqreen_http_request][:time_budget_expended] = true
245
+ next
253
246
  end
247
+ end
254
248
 
255
- flow = catch(Ball.new) do |ball|
256
- Timer.new(c.name) do |t|
257
- Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:timed_callbacks] << t
258
- end.measure do
259
- after_chrono.ignore do
260
- c.call(CallbackCall.new(c, remaining, hooked_call.instance, hooked_call.args_passing ? hooked_call.args_pass : hooked_call.args_passed, nil, hooked_call.returned), ball)
261
- end
262
- end
249
+ flow = catch(Ball.new) do |ball|
250
+ Timer.new(c.name, &timed_callbacks_proc).measure(ignore: chrono) do
251
+ c.call(CallbackCall.new(c, remaining, hooked_call.instance, hooked_call.args_passing ? hooked_call.args_pass : hooked_call.args_passed, nil, hooked_call.returned), ball)
263
252
  end
253
+ end
264
254
 
265
- next unless c.flow && flow.is_a?(Flow)
266
- hooked_call.raise = flow.raise and hooked_call.raising = true if flow.raise?
267
- hooked_call.return = flow.return and hooked_call.returning = true if flow.return?
268
- break if flow.break?
269
- end unless hook.disabled?
270
- end
255
+ next unless c.flow && flow.is_a?(Flow)
256
+ hooked_call.raise = flow.raise and hooked_call.raising = true if flow.raise?
257
+ hooked_call.return = flow.return and hooked_call.returning = true if flow.return?
258
+ break if flow.break?
259
+ end unless hook.disabled?
271
260
 
272
261
  raise hooked_call.raise if hooked_call.raising
273
262
  return hooked_call.returning ? hooked_call.return : hooked_call.returned
274
263
  ensure
275
264
  # TODO: timer.start if someone has thrown?
276
265
 
277
- Timer.new("#{hook.point}@ensured") do |t|
278
- Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:timed_hooks_ensured] << t
279
- end.measure do |ensured_chrono|
280
- hook.ensured.each do |c|
281
- next if c.ignore && c.ignore.call
282
-
283
- if timer && !c.mandatory
284
- remaining = budget - timer.elapsed
285
- unless remaining > 0
286
- Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:skipped_callbacks] << c && Thread.current[:sqreen_http_request][:time_budget_expended] = true
287
- next
288
- end
266
+ hook.ensured.each do |c|
267
+ next if c.ignore && c.ignore.call
268
+
269
+ if timer && !c.mandatory
270
+ remaining = budget - timer.elapsed
271
+ unless remaining > 0
272
+ Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:skipped_callbacks] << c && Thread.current[:sqreen_http_request][:time_budget_expended] = true
273
+ next
289
274
  end
275
+ end
290
276
 
291
- flow = catch(Ball.new) do |ball|
292
- Timer.new(c.name) do |t|
293
- Thread.current[:sqreen_http_request] && Thread.current[:sqreen_http_request][:timed_callbacks] << t
294
- end.measure do
295
- ensured_chrono.ignore do
296
- c.call(CallbackCall.new(c, remaining, hooked_call.instance, hooked_call.args_passing ? hooked_call.args_pass : hooked_call.args_passed, nil, hooked_call.returned), ball)
297
- end
298
- end
277
+ flow = catch(Ball.new) do |ball|
278
+ Timer.new(c.name, &timed_callbacks_proc).measure(ignore: chrono) do
279
+ c.call(CallbackCall.new(c, remaining, hooked_call.instance, hooked_call.args_passing ? hooked_call.args_pass : hooked_call.args_passed, nil, hooked_call.returned), ball)
299
280
  end
281
+ end
300
282
 
301
- next unless c.flow && flow.is_a?(Flow)
302
- hooked_call.raise = flow.raise and hooked_call.raising = true if flow.raise?
303
- hooked_call.return = flow.return and hooked_call.returning = true if flow.return?
304
- break if flow.break?
305
- end unless hook.disabled?
306
- end
283
+ next unless c.flow && flow.is_a?(Flow)
284
+ hooked_call.raise = flow.raise and hooked_call.raising = true if flow.raise?
285
+ hooked_call.return = flow.return and hooked_call.returning = true if flow.return?
286
+ break if flow.break?
287
+ end unless hook.disabled?
307
288
 
308
289
  Thread.current[:sqreen_hook_entered] = false
309
290
  timer.stop if timer
@@ -42,7 +42,7 @@ module Sqreen
42
42
  end
43
43
 
44
44
  def to_s
45
- "#{@klass_name}#{@method_kind == :instance_method ? '#' : '.'}#{@method_name}"
45
+ @to_s ||= "#{@klass_name}#{@method_kind == :instance_method ? '#' : '.'}#{@method_name}"
46
46
  end
47
47
 
48
48
  def exist?
@@ -109,7 +109,7 @@ module Legacy
109
109
  break if res.is_a?(Hash) && res[:skip_rem_cbs]
110
110
  rescue StandardError => e
111
111
  Sqreen.log.warn { "we catch an exception: #{e.inspect}" }
112
- Sqreen.log.debug e.backtrace
112
+ Sqreen.log.debug { e.backtrace }
113
113
  if cb.respond_to?(:record_exception)
114
114
  cb.record_exception(e)
115
115
  else
@@ -162,7 +162,7 @@ module Legacy
162
162
  returns << res
163
163
  rescue StandardError => e
164
164
  Sqreen.log.warn { "we catch an exception: #{e.inspect}" }
165
- Sqreen.log.debug e.backtrace
165
+ Sqreen.log.debug { e.backtrace }
166
166
  if cb.respond_to?(:record_exception)
167
167
  cb.record_exception(e)
168
168
  else
@@ -603,10 +603,10 @@ module Legacy
603
603
 
604
604
  if !already_overriden
605
605
  if is_class_method?(klass, method)
606
- Sqreen.log.debug "overriding class method for #{cb}"
606
+ Sqreen.log.debug { "overriding class method for #{cb}" }
607
607
  success = override_class_method(klass, method)
608
608
  elsif is_instance_method?(klass, method)
609
- Sqreen.log.debug "overriding instance method for #{cb}"
609
+ Sqreen.log.debug { "overriding instance method for #{cb}" }
610
610
  success = override_instance_method(klass, method)
611
611
  else
612
612
  # FIXME: Override define_method and other dynamic ways to
@@ -623,7 +623,7 @@ module Legacy
623
623
 
624
624
  @@overriden_methods += [key] if success
625
625
  else
626
- Sqreen.log.debug "#{key} was already overriden"
626
+ Sqreen.log.debug { "#{key} was already overriden" }
627
627
  end
628
628
 
629
629
  if klass != Object && klass != Kernel && !Sqreen.features['instrument_all_instances'] && !defined?(::JRUBY_VERSION)
@@ -638,7 +638,7 @@ module Legacy
638
638
  end
639
639
  end
640
640
 
641
- Sqreen.log.debug "Adding callback #{cb} for #{klass} #{method}"
641
+ Sqreen.log.debug { "Adding callback #{cb} for #{klass} #{method}" }
642
642
  @@registered_callbacks.add(cb)
643
643
  @@unovertimable_hookpoints << key unless cb.overtimeable
644
644
  @@instrumented_pid = Process.pid
@@ -659,7 +659,7 @@ module Legacy
659
659
 
660
660
  already_overriden = @@overriden_methods.include? key
661
661
  unless already_overriden
662
- Sqreen.log.debug "#{key} apparently not overridden"
662
+ Sqreen.log.debug { "#{key} apparently not overridden" }
663
663
  end
664
664
 
665
665
  defined_cbs = @@registered_callbacks.get(klass, method).flatten
@@ -667,17 +667,17 @@ module Legacy
667
667
  nb_removed = 0
668
668
  defined_cbs.each do |found_cb|
669
669
  if found_cb == cb
670
- Sqreen.log.debug "Removing callback #{found_cb}"
670
+ Sqreen.log.debug { "Removing callback #{found_cb}" }
671
671
  @@registered_callbacks.remove(found_cb)
672
672
  nb_removed += 1
673
673
  else
674
- Sqreen.log.debug "Not removing callback #{found_cb} (remains #{defined_cbs.size} cbs)"
674
+ Sqreen.log.debug { "Not removing callback #{found_cb} (remains #{defined_cbs.size} cbs)" }
675
675
  end
676
676
  end
677
677
 
678
678
  return unless nb_removed == defined_cbs.size
679
679
 
680
- Sqreen.log.debug "Removing overriden method #{key}"
680
+ Sqreen.log.debug { "Removing overriden method #{key}" }
681
681
  @@overriden_methods.delete(key)
682
682
 
683
683
  if is_class_method?(klass, method)
@@ -4,6 +4,7 @@
4
4
  # Please refer to our terms for more information: https://www.sqreen.com/terms.html
5
5
 
6
6
  require 'logger'
7
+ require 'sqreen/log'
7
8
 
8
9
  module Sqreen; end
9
10
  module Sqreen::Log; end
@@ -28,6 +28,10 @@ module Sqreen
28
28
  create_error_logger
29
29
  end
30
30
 
31
+ def debug?
32
+ @logger.debug?
33
+ end
34
+
31
35
  def debug(msg = nil, &block)
32
36
  @logger.debug(msg, &block)
33
37
  end
@@ -4,5 +4,5 @@
4
4
  # Please refer to our terms for more information: https://www.sqreen.com/terms.html
5
5
 
6
6
  module Sqreen
7
- VERSION = '1.20.1'.freeze
7
+ VERSION = '1.20.2'.freeze
8
8
  end
@@ -60,6 +60,27 @@ class Sqreen::Weave::Legacy::Instrumentation
60
60
  'options' => opts[:perf_metric_percent] || { 'base' => 1.3, 'factor' => 1.0 },
61
61
  )
62
62
 
63
+ metrics_engine.create_metric(
64
+ 'name' => 'req_sq_hook_overhead',
65
+ 'period' => 60,
66
+ 'kind' => 'Binning',
67
+ 'options' => { 'base' => 2.0, 'factor' => 0.1 },
68
+ )
69
+
70
+ metrics_engine.create_metric(
71
+ 'name' => 'sq.hook.overhead',
72
+ 'period' => 60,
73
+ 'kind' => 'Binning',
74
+ 'options' => { 'base' => 2.0, 'factor' => 0.1 },
75
+ )
76
+
77
+ metrics_engine.create_metric(
78
+ 'name' => 'sq.shrinkwrap',
79
+ 'period' => 60,
80
+ 'kind' => 'Binning',
81
+ 'options' => { 'base' => 2.0, 'factor' => 0.1 },
82
+ )
83
+
63
84
  Sqreen.thread_cpu_time? && metrics_engine.create_metric(
64
85
  'name' => 'sq_thread_cpu_pct',
65
86
  'period' => opts[:period] || 60,
@@ -113,6 +134,9 @@ class Sqreen::Weave::Legacy::Instrumentation
113
134
  before('wave,meta,request', rank: -100000, mandatory: true) do |_call|
114
135
  next unless Sqreen.instrumentation_ready
115
136
 
137
+ # shrinkwrap_timer = Sqreen::Graft::Timer.new('weave,shrinkwrap')
138
+ # shrinkwrap_timer.start
139
+
116
140
  uuid = SecureRandom.uuid
117
141
  now = Sqreen::Graft::Timer.read
118
142
  Thread.current[:sqreen_http_request] = {
@@ -123,14 +147,13 @@ class Sqreen::Weave::Legacy::Instrumentation
123
147
  timer: Sqreen::Graft::Timer.new("request_#{uuid}"),
124
148
  timed_callbacks: [],
125
149
  timed_hooks: [],
126
- timed_hooks_before: [],
127
- timed_hooks_after: [],
128
- timed_hooks_raised: [],
129
- timed_hooks_ensured: [],
130
150
  skipped_callbacks: [],
151
+ # timed_shrinkwrap: shrinkwrap_timer,
131
152
  }
132
153
 
133
154
  Sqreen::Weave.logger.debug { "request.uuid: #{uuid}" }
155
+
156
+ # shrinkwrap_timer.stop
134
157
  end
135
158
 
136
159
  ensured('weave,meta,request', rank: 100000, mandatory: true) do |_call|
@@ -138,6 +161,9 @@ class Sqreen::Weave::Legacy::Instrumentation
138
161
 
139
162
  next if request.nil?
140
163
 
164
+ # shrinkwrap_timer = request[:timed_shrinkwrap]
165
+ # shrinkwrap_timer.start
166
+
141
167
  Thread.current[:sqreen_http_request] = nil
142
168
  now = Sqreen::Graft::Timer.read
143
169
  utc_now = Time.now.utc
@@ -167,59 +193,28 @@ class Sqreen::Weave::Legacy::Instrumentation
167
193
  metrics_engine.update(metric_name, now, nil, duration * 1000)
168
194
  end
169
195
 
170
- metric_name = 'sq.hooks_pre.pre'
171
- duration = request[:timed_hooks_before].sum(&:duration)
172
- unless metrics_engine.metric?(metric_name)
173
- metrics_engine.create_metric(
174
- 'name' => metric_name,
175
- 'period' => 60,
176
- 'kind' => 'Binning',
177
- 'options' => { 'base' => 2.0, 'factor' => 0.1 },
178
- )
179
- end
180
- metrics_engine.update(metric_name, now, nil, duration * 1000)
181
-
182
- metric_name = 'sq.hooks_post.post'
183
- duration = request[:timed_hooks_after].sum(&:duration)
184
- unless metrics_engine.metric?(metric_name)
185
- metrics_engine.create_metric(
186
- 'name' => metric_name,
187
- 'period' => 60,
188
- 'kind' => 'Binning',
189
- 'options' => { 'base' => 2.0, 'factor' => 0.1 },
190
- )
191
- end
192
- metrics_engine.update(metric_name, now, nil, duration * 1000)
193
-
194
- metric_name = 'sq.hooks_failing.failing'
195
- duration = request[:timed_hooks_raised].sum(&:duration)
196
- unless metrics_engine.metric?(metric_name)
197
- metrics_engine.create_metric(
198
- 'name' => metric_name,
199
- 'period' => 60,
200
- 'kind' => 'Binning',
201
- 'options' => { 'base' => 2.0, 'factor' => 0.1 },
202
- )
196
+ request[:timed_hooks].each do |timer|
197
+ duration = timer.duration
198
+ metrics_engine.update('sq.hook.overhead', now, nil, duration * 1000)
203
199
  end
204
- metrics_engine.update(metric_name, now, nil, duration * 1000)
205
200
 
206
201
  skipped = request[:skipped_callbacks].map(&:name)
207
- Sqreen::Weave.logger.debug { "request:#{request[:uuid]} callback.skipped.size: #{skipped.count} callback.skipped: [#{skipped.join(', ')}]" }
202
+ Sqreen::Weave.logger.debug { "request:#{request[:uuid]} callback.skipped.size: #{skipped.count} callback.skipped: [#{skipped.join(', ')}]" } if Sqreen::Weave.logger.debug?
208
203
  timer = request[:timer]
209
204
  total = timer.duration
210
- Sqreen::Weave.logger.debug { "request:#{request[:uuid]} timer.total: #{'%.03fus' % (total * 1_000_000)} timer.size: #{timer.size}" }
205
+ Sqreen::Weave.logger.debug { "request:#{request[:uuid]} timer.total: #{'%.03fus' % (total * 1_000_000)}" } if Sqreen::Weave.logger.debug?
211
206
  timings = request[:timed_callbacks].map(&:to_s)
212
207
  total = request[:timed_callbacks].sum(&:duration)
213
- Sqreen::Weave.logger.debug { "request:#{request[:uuid]} callback.total: #{'%.03fus' % (total * 1_000_000)} callback.timings: [#{timings.join(', ')}]" }
208
+ Sqreen::Weave.logger.debug { "request:#{request[:uuid]} callback.total: #{'%.03fus' % (total * 1_000_000)} callback.timings: [#{timings.join(', ')}]" } if Sqreen::Weave.logger.debug?
214
209
  timings = request[:timed_hooks].map(&:to_s)
215
210
  total = request[:timed_hooks].sum(&:duration)
216
- Sqreen::Weave.logger.debug { "request:#{request[:uuid]} hook.total: #{'%.03fus' % (total * 1_000_000)} hook.timings: [#{timings.join(', ')}]" }
211
+ Sqreen::Weave.logger.debug { "request:#{request[:uuid]} hook.total: #{'%.03fus' % (total * 1_000_000)} hook.timings: [#{timings.join(', ')}]" } if Sqreen::Weave.logger.debug?
217
212
 
218
213
  skipped = request[:skipped_callbacks].map(&:name)
219
214
  skipped_rule_name = skipped.first && skipped.first =~ /weave,rule=(.*)$/ && $1
220
215
  Sqreen.observations_queue.push(['request_overtime', skipped_rule_name, 1, utc_now]) if skipped_rule_name
221
216
 
222
- sqreen_request_duration = total
217
+ sqreen_request_duration = request[:timed_hooks].sum(&:duration) + request[:timed_callbacks].sum(&:duration)
223
218
  Sqreen.observations_queue.push(['sq', nil, sqreen_request_duration * 1000, utc_now])
224
219
 
225
220
  request_duration = now - request[:start_time]
@@ -227,6 +222,14 @@ class Sqreen::Weave::Legacy::Instrumentation
227
222
 
228
223
  sqreen_request_ratio = (sqreen_request_duration * 100.0) / (request_duration - sqreen_request_duration)
229
224
  Sqreen.observations_queue.push(['pct', nil, sqreen_request_ratio, utc_now])
225
+
226
+ duration = request[:timed_hooks].sum(&:duration)
227
+ metrics_engine.update('req_sq_hook_overhead', now, nil, duration * 1000)
228
+
229
+ # shrinkwrap_timer.stop
230
+
231
+ # duration = shrinkwrap_timer.duration
232
+ # metrics_engine.update('sq.shrinkwrap', now, nil, duration * 1000)
230
233
  end
231
234
  end.install
232
235
 
@@ -275,7 +278,7 @@ class Sqreen::Weave::Legacy::Instrumentation
275
278
  a = call.args
276
279
  r = call.remaining
277
280
 
278
- Sqreen::Weave.logger.debug { "#{rule} klass=#{callback.klass} method=#{callback.method} when=#pre instance=#{i}" }
281
+ Sqreen::Weave.logger.debug { "#{rule} klass=#{callback.klass} method=#{callback.method} when=#pre instance=#{i}" } if Sqreen::Weave.logger.debug?
279
282
  begin
280
283
  ret = callback.pre(i, a, r)
281
284
  rescue StandardError => e
@@ -286,7 +289,7 @@ class Sqreen::Weave::Legacy::Instrumentation
286
289
  Sqreen::RemoteException.record(e)
287
290
  end
288
291
  end
289
- Sqreen::Weave.logger.debug { "#{rule} klass=#{callback.klass} method=#{callback.method} when=#pre instance=#{i} => return=#{ret.inspect}" }
292
+ Sqreen::Weave.logger.debug { "#{rule} klass=#{callback.klass} method=#{callback.method} when=#pre instance=#{i} => return=#{ret.inspect}" } if Sqreen::Weave.logger.debug?
290
293
 
291
294
  case ret[:status]
292
295
  when :skip, 'skip'
@@ -309,7 +312,7 @@ class Sqreen::Weave::Legacy::Instrumentation
309
312
  a = call.args
310
313
  r = call.remaining
311
314
 
312
- Sqreen::Weave.logger.debug { "#{rule} klass=#{callback.klass} method=#{callback.method} when=#post instance=#{i}" }
315
+ Sqreen::Weave.logger.debug { "#{rule} klass=#{callback.klass} method=#{callback.method} when=#post instance=#{i}" } if Sqreen::Weave.logger.debug?
313
316
  begin
314
317
  ret = callback.post(v, i, a, r)
315
318
  rescue StandardError => e
@@ -320,7 +323,7 @@ class Sqreen::Weave::Legacy::Instrumentation
320
323
  Sqreen::RemoteException.record(e)
321
324
  end
322
325
  end
323
- Sqreen::Weave.logger.debug { "#{rule} klass=#{callback.klass} method=#{callback.method} when=#post instance=#{i} => return=#{ret.inspect}" }
326
+ Sqreen::Weave.logger.debug { "#{rule} klass=#{callback.klass} method=#{callback.method} when=#post instance=#{i} => return=#{ret.inspect}" } if Sqreen::Weave.logger.debug?
324
327
 
325
328
  case ret[:status]
326
329
  when :override, 'override'
@@ -341,7 +344,7 @@ class Sqreen::Weave::Legacy::Instrumentation
341
344
  a = call.args
342
345
  r = call.remaining
343
346
 
344
- Sqreen::Weave.logger.debug { "#{rule} klass=#{callback.klass} method=#{callback.method} when=#failing instance=#{i}" }
347
+ Sqreen::Weave.logger.debug { "#{rule} klass=#{callback.klass} method=#{callback.method} when=#failing instance=#{i}" } if Sqreen::Weave.logger.debug?
345
348
  begin
346
349
  ret = callback.failing(e, i, a, r)
347
350
  rescue StandardError => e
@@ -352,7 +355,7 @@ class Sqreen::Weave::Legacy::Instrumentation
352
355
  Sqreen::RemoteException.record(e)
353
356
  end
354
357
  end
355
- Sqreen::Weave.logger.debug { "#{rule} klass=#{callback.klass} method=#{callback.method} when=#failing instance=#{i} => return=#{ret.inspect}" }
358
+ Sqreen::Weave.logger.debug { "#{rule} klass=#{callback.klass} method=#{callback.method} when=#failing instance=#{i} => return=#{ret.inspect}" } if Sqreen::Weave.logger.debug?
356
359
 
357
360
  throw(b, b.raise(e)) if ret.nil? || !ret.is_a?(Hash)
358
361
 
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.20.1
4
+ version: 1.20.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sqreen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-24 00:00:00.000000000 Z
11
+ date: 2020-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqreen-backport
@@ -292,8 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
292
292
  - !ruby/object:Gem::Version
293
293
  version: '0'
294
294
  requirements: []
295
- rubyforge_project:
296
- rubygems_version: 2.7.7
295
+ rubygems_version: 3.1.2
297
296
  signing_key:
298
297
  specification_version: 4
299
298
  summary: Sqreen Ruby agent