rack-honeycomb 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rack/honeycomb/middleware.rb +39 -12
- data/lib/rack/honeycomb/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: 2df72a49bca0dd5e2665baf5761f34a21f1140e718f26c1df5f72994e332b77b
|
4
|
+
data.tar.gz: 6a3743e0c01dc73c1b503a6e0103c77fb0c7aacaef83c1a9c1b01449aec393c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f81063f7b9acc8e374408a8ef8c18c8b6b20ddf78ba7ab0faf2e2c0abd5716b8931968aac459abd77e4dfc92330d596e18759045808a1f96fd7174a025fee277
|
7
|
+
data.tar.gz: f7579b4e2074b46164345c437814889a2cb7b30cffceb9a43a36cc22e4c8eb5795741e034f72a1e3d7a32420f6ac905eb73597a2b584c81b77b7f9329d80cb6c
|
@@ -77,7 +77,7 @@ module Rack
|
|
77
77
|
add_request_fields(ev, env)
|
78
78
|
|
79
79
|
start = Time.now
|
80
|
-
status, headers, body =
|
80
|
+
status, headers, body = with_tracing_if_available(ev, env) do
|
81
81
|
@app.call(env)
|
82
82
|
end
|
83
83
|
|
@@ -186,8 +186,8 @@ module Rack
|
|
186
186
|
# anything inside the Rack handler.
|
187
187
|
env.each_pair do |k, v|
|
188
188
|
if k.is_a?(String) && k.match(ENV_REGEX)
|
189
|
-
|
190
|
-
event
|
189
|
+
field_name = k.sub(ENV_REGEX, '')
|
190
|
+
add_app_field(event, field_name, v)
|
191
191
|
env.delete(k)
|
192
192
|
end
|
193
193
|
end
|
@@ -197,18 +197,45 @@ module Rack
|
|
197
197
|
event.add_field('response.status_code', status)
|
198
198
|
end
|
199
199
|
|
200
|
-
def
|
201
|
-
return
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
200
|
+
def with_tracing_if_available(event, env)
|
201
|
+
# return if we are not using the ruby beeline
|
202
|
+
return yield unless defined?(::Honeycomb)
|
203
|
+
|
204
|
+
# beeline version <= 0.5.0
|
205
|
+
if ::Honeycomb.respond_to? :with_trace_id
|
206
|
+
::Honeycomb.with_trace_id do |trace_id|
|
207
|
+
event.add_field "trace.trace_id", trace_id
|
208
|
+
# so this shows up as a root span
|
209
|
+
event.add_field "trace.span_id", trace_id
|
210
|
+
::Honeycomb.with_span_id(trace_id) do
|
211
|
+
yield
|
212
|
+
end
|
213
|
+
end
|
214
|
+
# beeline version > 0.5.0
|
215
|
+
elsif ::Honeycomb.respond_to? :trace_from_encoded_context
|
216
|
+
encoded_context = trace_context_from_header(env)
|
217
|
+
::Honeycomb.trace_from_encoded_context(encoded_context) do
|
218
|
+
::Honeycomb.span_for_existing_event(
|
219
|
+
event,
|
220
|
+
name: nil, # this is only added if it is present, we set the name in #add_request_fields
|
221
|
+
type: EVENT_TYPE,
|
222
|
+
) do
|
223
|
+
yield
|
224
|
+
end
|
209
225
|
end
|
226
|
+
# fallback if we don't detect any known beeline tracing methods
|
227
|
+
else
|
228
|
+
yield
|
210
229
|
end
|
211
230
|
end
|
231
|
+
|
232
|
+
def trace_context_from_header(env)
|
233
|
+
env['HTTP_X_HONEYCOMB_TRACE']
|
234
|
+
end
|
235
|
+
|
236
|
+
def add_app_field(event, k, v)
|
237
|
+
event.add_field "#{APP_FIELD_NAMESPACE}.#{k}", v
|
238
|
+
end
|
212
239
|
end
|
213
240
|
|
214
241
|
class << self
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-honeycomb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Honeycomb.io Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bump
|