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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87942acd38f5a7ec92e37e9edeca57b7c475c445b2774f9c4a92f6f7d926f0d1
4
- data.tar.gz: 153711d7c16fc72fd2466ee15b7ffe9c04eca428695e0bcb1cd98f650c648f83
3
+ metadata.gz: cfe839ce437cd3fd95a31f9abcd8ed59acc62b4094b04b1e95d57246ad4bea0e
4
+ data.tar.gz: e892e9ada926776887a9eb731ea8bbadad87c201d15c5f0890422146d1255c02
5
5
  SHA512:
6
- metadata.gz: 3ac383fef4a60b694b89f946f826d294d21fc2bc1e8dda52b31fc6f1cba795bfe8d7bbef30541ee1a1682545fd693837ca8a144fb3e73abbe33637bfa0165e20
7
- data.tar.gz: b1912defa21adced2b1133c1fcf3b0d1a706afb1dc8160216fca2b78cbe4d79a962d390e4570dce393be2721c0263e94b90fdcd4fd49cd2db32e75b2de26a744
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')
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module Honeycomb
3
- VERSION="0.0.14"
3
+ VERSION="0.0.15"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-honeycomb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Honeycomb.io Team