skylight 1.7.0 → 1.7.1
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 +3 -0
- data/lib/skylight/probes/middleware.rb +13 -3
- data/lib/skylight/trace.rb +45 -18
- data/lib/skylight/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: ad288b69779cb31529b64adbc47d976b06f5300cbb7ff0687b94d412880311dc
|
4
|
+
data.tar.gz: de757d14b9080b43e2e0d139965fade57bcaabe924e975b4b46ddbe1f7907563
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 023eff94d6cacf557aeac45a4fee501bf90ac4595d58a671789f3bb6b4726230be6fe3b36805af173809226bbc8c1181d0c073f45d935486da818b824ae47f3f
|
7
|
+
data.tar.gz: 4e538a415d63cd62208c6b51ed816e0202e20b9ffc926628e631eeedd896d6dc3c95d83bfc24d1894e83664dadee68a0b80d94e49c2207c5c55b286c333b6e61
|
data/CHANGELOG.md
CHANGED
@@ -17,11 +17,21 @@ module Skylight
|
|
17
17
|
span = Skylight.instrument(title: name, category: "#{category}")
|
18
18
|
resp = call_without_sk(*args, &block)
|
19
19
|
|
20
|
-
Skylight::Middleware.with_after_close(resp)
|
21
|
-
|
20
|
+
proxied_response = Skylight::Middleware.with_after_close(resp) do
|
21
|
+
trace.done(span)
|
22
|
+
end
|
23
|
+
rescue Exception => err
|
22
24
|
# FIXME: Log this?
|
23
|
-
trace.done(span)
|
25
|
+
trace.done(span, exception_object: err)
|
24
26
|
raise
|
27
|
+
ensure
|
28
|
+
unless err || proxied_response
|
29
|
+
# If we've gotten to this point, the most likely scenario is that
|
30
|
+
# a throw/catch has bypassed a portion of the callstack. Since these spans would not otherwise
|
31
|
+
# be closed, mark them deferred to indicate that they should be implicitly closed.
|
32
|
+
# See Core::Trace#deferred_spans or Core::Trace#stop for more information.
|
33
|
+
trace.done(span, defer: true)
|
34
|
+
end
|
25
35
|
end
|
26
36
|
end
|
27
37
|
RUBY
|
data/lib/skylight/trace.rb
CHANGED
@@ -95,9 +95,15 @@ module Skylight
|
|
95
95
|
nil
|
96
96
|
end
|
97
97
|
|
98
|
-
def done(span)
|
98
|
+
def done(span, meta=nil)
|
99
99
|
return unless span
|
100
100
|
return if broken?
|
101
|
+
|
102
|
+
if meta && meta[:defer]
|
103
|
+
deferred_spans[span] ||= (Util::Clock.nanos - gc_time)
|
104
|
+
return
|
105
|
+
end
|
106
|
+
|
101
107
|
stop(span, Util::Clock.nanos - gc_time)
|
102
108
|
rescue => e
|
103
109
|
error "failed to close span; msg=%s; endpoint=%s", e.message, endpoint
|
@@ -105,6 +111,13 @@ module Skylight
|
|
105
111
|
nil
|
106
112
|
end
|
107
113
|
|
114
|
+
# Middleware spans that were interrupted by a throw/catch should be cached here.
|
115
|
+
# keys: span ids
|
116
|
+
# values: nsec timestamp at which the span was cached here.
|
117
|
+
def deferred_spans
|
118
|
+
@deferred_spans ||= {}
|
119
|
+
end
|
120
|
+
|
108
121
|
def release
|
109
122
|
return unless @instrumenter.current_trace == self
|
110
123
|
@instrumenter.current_trace = nil
|
@@ -171,29 +184,43 @@ module Skylight
|
|
171
184
|
def stop(span, time)
|
172
185
|
t { "stopping span: #{span}" }
|
173
186
|
|
174
|
-
|
175
|
-
|
176
|
-
|
187
|
+
# If `stop` is called for a span that is not the last item in the stack,
|
188
|
+
# check to see if the last item has been marked as deferred. If so, close
|
189
|
+
# that span first, then try to close the original.
|
190
|
+
while deferred_spans[expected = @spans.pop]
|
191
|
+
normalized_stop(expected, deferred_spans.delete(expected))
|
192
|
+
end
|
193
|
+
|
194
|
+
handle_unexpected_stop(expected, span) unless span == expected
|
177
195
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
"the Rack SPEC."
|
182
|
-
else
|
183
|
-
message << "To debug this issue set `SKYLIGHT_ENABLE_TRACE_LOGS=true` " \
|
184
|
-
"in your environment. (Beware, it is quite noisy!)\n"
|
185
|
-
end
|
196
|
+
normalized_stop(span, time)
|
197
|
+
nil
|
198
|
+
end
|
186
199
|
|
187
|
-
|
200
|
+
def normalized_stop(span, time)
|
201
|
+
time = self.class.normalize_time(time)
|
202
|
+
native_stop_span(span, time)
|
203
|
+
end
|
188
204
|
|
189
|
-
|
205
|
+
def handle_unexpected_stop(expected, span)
|
206
|
+
message = "[E0001] Spans were closed out of order.\n"
|
190
207
|
|
191
|
-
|
208
|
+
if Skylight::Util::Logging.trace?
|
209
|
+
message << "Expected #{expected}, but received #{span}. See prior logs to match id to a name.\n" \
|
210
|
+
"If the received span was a Middleware it may be one that doesn't fully conform to " \
|
211
|
+
"the Rack SPEC."
|
212
|
+
else
|
213
|
+
message << "To debug this issue set `SKYLIGHT_ENABLE_TRACE_LOGS=true` " \
|
214
|
+
"in your environment. (Beware, it is quite noisy!)\n"
|
192
215
|
end
|
193
216
|
|
194
|
-
|
195
|
-
|
196
|
-
|
217
|
+
message << "\nThis request will not be tracked. Please contact support@skylight.io for more information."
|
218
|
+
|
219
|
+
error message
|
220
|
+
|
221
|
+
t { "expected=#{expected}, actual=#{span}" }
|
222
|
+
|
223
|
+
broken!
|
197
224
|
end
|
198
225
|
|
199
226
|
def gc_time
|
data/lib/skylight/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skylight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tilde, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|