rack-honeycomb 0.0.14 → 0.0.15
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 +14 -0
- data/lib/rack/honeycomb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfe839ce437cd3fd95a31f9abcd8ed59acc62b4094b04b1e95d57246ad4bea0e
|
4
|
+
data.tar.gz: e892e9ada926776887a9eb731ea8bbadad87c201d15c5f0890422146d1255c02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1fe4cb326c7948d7e82bfdcd53979e3cfbbe2c448494819e74471a489afdc56e8192cca3843a85bb7d9f6cc5492fe52c891a4a58c1aae9fc6ce289b1dda991c
|
7
|
+
data.tar.gz: 3a583b5fdd375da03982e26c0163bb7d75203c332268cf30bbfc0138de1ac236dc013bdf81549f3310896a6ea1e161d496ce1f0c5b0fa877a03835106209e236
|
@@ -2,8 +2,13 @@ require "libhoney"
|
|
2
2
|
|
3
3
|
module Rack
|
4
4
|
module Honeycomb
|
5
|
+
# Prefix for attaching arbitrary metadata to the `env`. Will be deleted from
|
6
|
+
# the `env` once it's pulled off of the `env` and onto a Honeycomb event.
|
7
|
+
ENV_PREFIX = "honeycomb."
|
5
8
|
|
6
9
|
class Middleware
|
10
|
+
HEADER_REGEX = /^#{ Regexp.escape ENV_PREFIX }/
|
11
|
+
|
7
12
|
attr_reader :app
|
8
13
|
attr_reader :options
|
9
14
|
|
@@ -43,6 +48,15 @@ module Rack
|
|
43
48
|
add_field(ev, 'HTTP_STATUS', status)
|
44
49
|
add_field(ev, 'REQUEST_TIME_MS', (request_ended_at - request_started_at) * 1000)
|
45
50
|
|
51
|
+
# Pull arbitrary metadata off `env` if the caller attached anything
|
52
|
+
# inside the Rack handler.
|
53
|
+
env.each_pair do |k, v|
|
54
|
+
if k.is_a?(String) && k.match(HEADER_REGEX)
|
55
|
+
add_field(ev, k.sub(HEADER_REGEX, ''), v)
|
56
|
+
env.delete(k)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
46
60
|
# we can't use `ev.add(env)` because json serialization fails.
|
47
61
|
# pull out some interesting and potentially useful fields.
|
48
62
|
add_env(ev, env, 'rack.version')
|