honeycomb-beeline 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +54 -18
- data/.rubocop.yml +2 -0
- data/Appraisals +11 -2
- data/Gemfile.lock +8 -8
- data/honeycomb-beeline.gemspec +1 -1
- data/lib/generators/honeycomb/honeycomb_generator.rb +14 -0
- data/lib/honeycomb-beeline.rb +2 -1
- data/lib/honeycomb/beeline/version.rb +1 -1
- data/lib/honeycomb/client.rb +22 -11
- data/lib/honeycomb/integrations/active_support.rb +3 -1
- data/lib/honeycomb/integrations/aws.rb +5 -1
- data/lib/honeycomb/integrations/faraday.rb +1 -1
- data/lib/honeycomb/integrations/rack.rb +8 -1
- data/lib/honeycomb/integrations/rails.rb +70 -20
- data/lib/honeycomb/integrations/railtie.rb +2 -3
- data/lib/honeycomb/integrations/redis.rb +3 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2f8be462c8910f16abb2dadf83da771cbfcb11dd2cf6525455bdd23af17dfd0
|
4
|
+
data.tar.gz: 84bfc86f929938d8d079c7d615357ef1ca08e8dfe9be2d266c4cb57b2a9b1fec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aadcfaec026873e03f75012e0303c927a102dd4de060e04f4132c329a6e2e86312614e8e18486e9f4bafbb4c6acc1790b495f1c9bbd557361b02905df4ea48f
|
7
|
+
data.tar.gz: 6dcefe527d6b7d529c312a19d3e2c6f387e5cdd42342ddc3b49747de4dc96c95f575651750151c1ab60abb2463b8c7b5fecb5c816a8bae72ecf12e91288cd60f
|
data/.circleci/config.yml
CHANGED
@@ -53,10 +53,14 @@ gemfiles:
|
|
53
53
|
steps:
|
54
54
|
- ruby:
|
55
55
|
gemfile: gemfiles/aws_3.gemfile
|
56
|
-
faraday: &faraday
|
56
|
+
faraday-zero: &faraday-zero
|
57
57
|
steps:
|
58
58
|
- ruby:
|
59
|
-
gemfile: gemfiles/
|
59
|
+
gemfile: gemfiles/faraday_0.gemfile
|
60
|
+
faraday-one: &faraday-one
|
61
|
+
steps:
|
62
|
+
- ruby:
|
63
|
+
gemfile: gemfiles/faraday_1.gemfile
|
60
64
|
sequel-four: &sequel-four
|
61
65
|
steps:
|
62
66
|
- ruby:
|
@@ -145,17 +149,29 @@ jobs:
|
|
145
149
|
aws-three-ruby-two-six:
|
146
150
|
<<: *aws-three
|
147
151
|
executor: ruby-two-six
|
148
|
-
faraday-ruby-two-three:
|
149
|
-
<<: *faraday
|
152
|
+
faraday-zero-ruby-two-three:
|
153
|
+
<<: *faraday-zero
|
150
154
|
executor: ruby-two-three
|
151
|
-
faraday-ruby-two-four:
|
152
|
-
<<: *faraday
|
155
|
+
faraday-zero-ruby-two-four:
|
156
|
+
<<: *faraday-zero
|
153
157
|
executor: ruby-two-four
|
154
|
-
faraday-ruby-two-five:
|
155
|
-
<<: *faraday
|
158
|
+
faraday-zero-ruby-two-five:
|
159
|
+
<<: *faraday-zero
|
156
160
|
executor: ruby-two-five
|
157
|
-
faraday-ruby-two-six:
|
158
|
-
<<: *faraday
|
161
|
+
faraday-zero-ruby-two-six:
|
162
|
+
<<: *faraday-zero
|
163
|
+
executor: ruby-two-six
|
164
|
+
faraday-one-ruby-two-three:
|
165
|
+
<<: *faraday-one
|
166
|
+
executor: ruby-two-three
|
167
|
+
faraday-one-ruby-two-four:
|
168
|
+
<<: *faraday-one
|
169
|
+
executor: ruby-two-four
|
170
|
+
faraday-one-ruby-two-five:
|
171
|
+
<<: *faraday-one
|
172
|
+
executor: ruby-two-five
|
173
|
+
faraday-one-ruby-two-six:
|
174
|
+
<<: *faraday-one
|
159
175
|
executor: ruby-two-six
|
160
176
|
sequel-four-ruby-two-three:
|
161
177
|
<<: *sequel-four
|
@@ -339,19 +355,35 @@ workflows:
|
|
339
355
|
<<: *tag_filters
|
340
356
|
requires:
|
341
357
|
- lint
|
342
|
-
- faraday-ruby-two-three:
|
358
|
+
- faraday-zero-ruby-two-three:
|
359
|
+
<<: *tag_filters
|
360
|
+
requires:
|
361
|
+
- lint
|
362
|
+
- faraday-zero-ruby-two-four:
|
363
|
+
<<: *tag_filters
|
364
|
+
requires:
|
365
|
+
- lint
|
366
|
+
- faraday-zero-ruby-two-five:
|
367
|
+
<<: *tag_filters
|
368
|
+
requires:
|
369
|
+
- lint
|
370
|
+
- faraday-zero-ruby-two-six:
|
371
|
+
<<: *tag_filters
|
372
|
+
requires:
|
373
|
+
- lint
|
374
|
+
- faraday-one-ruby-two-three:
|
343
375
|
<<: *tag_filters
|
344
376
|
requires:
|
345
377
|
- lint
|
346
|
-
- faraday-ruby-two-four:
|
378
|
+
- faraday-one-ruby-two-four:
|
347
379
|
<<: *tag_filters
|
348
380
|
requires:
|
349
381
|
- lint
|
350
|
-
- faraday-ruby-two-five:
|
382
|
+
- faraday-one-ruby-two-five:
|
351
383
|
<<: *tag_filters
|
352
384
|
requires:
|
353
385
|
- lint
|
354
|
-
- faraday-ruby-two-six:
|
386
|
+
- faraday-one-ruby-two-six:
|
355
387
|
<<: *tag_filters
|
356
388
|
requires:
|
357
389
|
- lint
|
@@ -543,10 +575,14 @@ workflows:
|
|
543
575
|
- aws-three-ruby-two-four
|
544
576
|
- aws-three-ruby-two-five
|
545
577
|
- aws-three-ruby-two-six
|
546
|
-
- faraday-ruby-two-three
|
547
|
-
- faraday-ruby-two-four
|
548
|
-
- faraday-ruby-two-five
|
549
|
-
- faraday-ruby-two-six
|
578
|
+
- faraday-zero-ruby-two-three
|
579
|
+
- faraday-zero-ruby-two-four
|
580
|
+
- faraday-zero-ruby-two-five
|
581
|
+
- faraday-zero-ruby-two-six
|
582
|
+
- faraday-one-ruby-two-three
|
583
|
+
- faraday-one-ruby-two-four
|
584
|
+
- faraday-one-ruby-two-five
|
585
|
+
- faraday-one-ruby-two-six
|
550
586
|
- sequel-four-ruby-two-three
|
551
587
|
- sequel-four-ruby-two-four
|
552
588
|
- sequel-four-ruby-two-five
|
data/.rubocop.yml
CHANGED
data/Appraisals
CHANGED
@@ -8,8 +8,12 @@ appraise "aws-3" do
|
|
8
8
|
gem "aws-sdk", "~> 3"
|
9
9
|
end
|
10
10
|
|
11
|
-
appraise "faraday" do
|
12
|
-
gem "faraday"
|
11
|
+
appraise "faraday-0" do
|
12
|
+
gem "faraday", "~> 0"
|
13
|
+
end
|
14
|
+
|
15
|
+
appraise "faraday-1" do
|
16
|
+
gem "faraday", "~> 1"
|
13
17
|
end
|
14
18
|
|
15
19
|
appraise "sequel4" do
|
@@ -35,30 +39,35 @@ end
|
|
35
39
|
appraise "rails-41" do
|
36
40
|
gem "rack-test"
|
37
41
|
gem "rails", "~> 4.1.0"
|
42
|
+
gem "sprockets", "~> 3"
|
38
43
|
gem "warden"
|
39
44
|
end
|
40
45
|
|
41
46
|
appraise "rails-42" do
|
42
47
|
gem "rack-test"
|
43
48
|
gem "rails", "~> 4.2.0"
|
49
|
+
gem "sprockets", "~> 3"
|
44
50
|
gem "warden"
|
45
51
|
end
|
46
52
|
|
47
53
|
appraise "rails-5" do
|
48
54
|
gem "rack-test"
|
49
55
|
gem "rails", "~> 5.0.0"
|
56
|
+
gem "sprockets", "~> 3"
|
50
57
|
gem "warden"
|
51
58
|
end
|
52
59
|
|
53
60
|
appraise "rails-51" do
|
54
61
|
gem "rack-test"
|
55
62
|
gem "rails", "~> 5.1.0"
|
63
|
+
gem "sprockets", "~> 3"
|
56
64
|
gem "warden"
|
57
65
|
end
|
58
66
|
|
59
67
|
appraise "rails-52" do
|
60
68
|
gem "rack-test"
|
61
69
|
gem "rails", "~> 5.2.0"
|
70
|
+
gem "sprockets", "~> 3"
|
62
71
|
gem "warden"
|
63
72
|
end
|
64
73
|
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
honeycomb-beeline (
|
5
|
-
libhoney (~> 1.
|
4
|
+
honeycomb-beeline (2.0.0)
|
5
|
+
libhoney (~> 1.14, >= 1.14.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
@@ -31,20 +31,20 @@ GEM
|
|
31
31
|
ffi (>= 1.0.0)
|
32
32
|
rake
|
33
33
|
hashdiff (0.4.0)
|
34
|
-
http (4.
|
34
|
+
http (4.3.0)
|
35
35
|
addressable (~> 2.3)
|
36
36
|
http-cookie (~> 1.0)
|
37
|
-
http-form_data (~> 2.
|
37
|
+
http-form_data (~> 2.2)
|
38
38
|
http-parser (~> 1.2.0)
|
39
39
|
http-cookie (1.0.3)
|
40
40
|
domain_name (~> 0.5)
|
41
|
-
http-form_data (2.
|
41
|
+
http-form_data (2.3.0)
|
42
42
|
http-parser (1.2.1)
|
43
43
|
ffi-compiler (>= 1.0, < 2.0)
|
44
44
|
iniparse (1.4.4)
|
45
45
|
jaro_winkler (1.5.3)
|
46
46
|
json (2.2.0)
|
47
|
-
libhoney (1.14.
|
47
|
+
libhoney (1.14.4)
|
48
48
|
addressable (~> 2.0)
|
49
49
|
http (>= 2.0, < 5.0)
|
50
50
|
method_source (0.9.2)
|
@@ -62,7 +62,7 @@ GEM
|
|
62
62
|
pry (~> 0.10)
|
63
63
|
public_suffix (3.1.1)
|
64
64
|
rainbow (3.0.0)
|
65
|
-
rake (
|
65
|
+
rake (13.0.1)
|
66
66
|
rspec (3.8.0)
|
67
67
|
rspec-core (~> 3.8.0)
|
68
68
|
rspec-expectations (~> 3.8.0)
|
@@ -127,4 +127,4 @@ DEPENDENCIES
|
|
127
127
|
webmock
|
128
128
|
|
129
129
|
BUNDLED WITH
|
130
|
-
2.
|
130
|
+
2.1.4
|
data/honeycomb-beeline.gemspec
CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
38
38
|
spec.require_paths = ["lib"]
|
39
39
|
|
40
|
-
spec.add_dependency "libhoney", "~> 1.
|
40
|
+
spec.add_dependency "libhoney", ">= 1.14.2", "~> 1.14"
|
41
41
|
|
42
42
|
spec.add_development_dependency "appraisal"
|
43
43
|
spec.add_development_dependency "bump"
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "rails/generators"
|
4
|
+
require "active_support/core_ext/string/strip"
|
4
5
|
|
5
6
|
##
|
6
7
|
# Generates an intializer for configuring the Honeycomb beeline
|
@@ -22,6 +23,19 @@ class HoneycombGenerator < Rails::Generators::Base
|
|
22
23
|
Honeycomb.configure do |config|
|
23
24
|
config.write_key = #{write_key.inspect}
|
24
25
|
config.dataset = #{options['dataset'].inspect}
|
26
|
+
config.presend_hook do |fields|
|
27
|
+
if fields["name"] == "redis" && fields.has_key?("redis.command")
|
28
|
+
# remove potential PII from the redis command
|
29
|
+
if fields["redis.command"].respond_to? :split
|
30
|
+
fields["redis.command"] = fields["redis.command"].split.first
|
31
|
+
end
|
32
|
+
end
|
33
|
+
if fields["name"] == "sql.active_record"
|
34
|
+
# remove potential PII from the active record events
|
35
|
+
fields.delete("sql.active_record.binds")
|
36
|
+
fields.delete("sql.active_record.type_casted_binds")
|
37
|
+
end
|
38
|
+
end
|
25
39
|
config.notification_events = %w[
|
26
40
|
sql.active_record
|
27
41
|
render_template.action_view
|
data/lib/honeycomb-beeline.rb
CHANGED
@@ -25,7 +25,8 @@ module Honeycomb
|
|
25
25
|
extend Forwardable
|
26
26
|
attr_reader :client
|
27
27
|
|
28
|
-
def_delegators :@client, :start_span, :add_field,
|
28
|
+
def_delegators :@client, :libhoney, :start_span, :add_field,
|
29
|
+
:add_field_to_trace, :current_span, :current_trace
|
29
30
|
|
30
31
|
def configure
|
31
32
|
Configuration.new.tap do |config|
|
data/lib/honeycomb/client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "forwardable"
|
3
4
|
require "honeycomb/beeline/version"
|
4
5
|
require "honeycomb/configuration"
|
5
6
|
require "honeycomb/context"
|
@@ -7,18 +8,28 @@ require "honeycomb/context"
|
|
7
8
|
module Honeycomb
|
8
9
|
# The Honeycomb Beeline client
|
9
10
|
class Client
|
11
|
+
extend Forwardable
|
12
|
+
|
13
|
+
attr_reader :libhoney
|
14
|
+
|
15
|
+
def_delegators :@context, :current_span, :current_trace
|
16
|
+
|
10
17
|
def initialize(configuration:)
|
11
|
-
@
|
18
|
+
@libhoney = configuration.client
|
12
19
|
# attempt to set the user_agent_addition, this will only work if the
|
13
20
|
# client has not sent an event prior to being passed in here. This should
|
14
21
|
# be most cases
|
15
|
-
@
|
16
|
-
|
17
|
-
@
|
18
|
-
@
|
22
|
+
@libhoney.instance_variable_set(:@user_agent_addition,
|
23
|
+
Honeycomb::Beeline::USER_AGENT_SUFFIX)
|
24
|
+
@libhoney.add_field "meta.beeline_version", Honeycomb::Beeline::VERSION
|
25
|
+
@libhoney.add_field "meta.local_hostname", configuration.host_name
|
26
|
+
|
27
|
+
integrations = Honeycomb.integrations_to_load
|
28
|
+
@libhoney.add_field "meta.instrumentations_count", integrations.count
|
29
|
+
@libhoney.add_field "meta.instrumentations", integrations.map(&:to_s).to_s
|
19
30
|
|
20
31
|
# maybe make `service_name` a required parameter
|
21
|
-
@
|
32
|
+
@libhoney.add_field "service_name", configuration.service_name
|
22
33
|
@context = Context.new
|
23
34
|
|
24
35
|
@additional_trace_options = {
|
@@ -29,14 +40,14 @@ module Honeycomb
|
|
29
40
|
configuration.after_initialize(self)
|
30
41
|
|
31
42
|
at_exit do
|
32
|
-
|
43
|
+
libhoney.close
|
33
44
|
end
|
34
45
|
end
|
35
46
|
|
36
47
|
def start_span(name:, serialized_trace: nil, **fields)
|
37
48
|
if context.current_trace.nil?
|
38
49
|
Trace.new(serialized_trace: serialized_trace,
|
39
|
-
builder:
|
50
|
+
builder: libhoney.builder,
|
40
51
|
context: context,
|
41
52
|
**@additional_trace_options)
|
42
53
|
else
|
@@ -53,8 +64,8 @@ module Honeycomb
|
|
53
64
|
begin
|
54
65
|
yield context.current_span
|
55
66
|
rescue StandardError => e
|
56
|
-
context.current_span.add_field("
|
57
|
-
context.current_span.add_field("
|
67
|
+
context.current_span.add_field("error", e.class.name)
|
68
|
+
context.current_span.add_field("error_detail", e.message)
|
58
69
|
raise e
|
59
70
|
ensure
|
60
71
|
context.current_span.send
|
@@ -78,6 +89,6 @@ module Honeycomb
|
|
78
89
|
|
79
90
|
private
|
80
91
|
|
81
|
-
attr_reader :
|
92
|
+
attr_reader :context
|
82
93
|
end
|
83
94
|
end
|
@@ -34,7 +34,9 @@ module Honeycomb
|
|
34
34
|
on_notification_event.call(name, span, payload)
|
35
35
|
else
|
36
36
|
payload.each do |key, value|
|
37
|
-
|
37
|
+
# Make ActionController::Parameters parseable by libhoney.
|
38
|
+
value = value.to_unsafe_hash if value.respond_to?(:to_unsafe_hash)
|
39
|
+
span.add_field("#{name}.#{key}", value)
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
@@ -106,8 +106,12 @@ module Honeycomb
|
|
106
106
|
"aws.region" => context.config.region,
|
107
107
|
"aws.service" => context.client.class.identifier,
|
108
108
|
"aws.operation" => context.operation_name,
|
109
|
-
"aws.params" => context.params,
|
110
109
|
}
|
110
|
+
|
111
|
+
context.params && context.params.each do |key, value|
|
112
|
+
context[:honeycomb_aws_sdk_data]["aws.params.#{key}"] = value
|
113
|
+
end
|
114
|
+
|
111
115
|
span.add context[:honeycomb_aws_sdk_data]
|
112
116
|
end
|
113
117
|
|
@@ -15,7 +15,7 @@ module Honeycomb
|
|
15
15
|
|
16
16
|
@client.start_span(name: "http_client") do |span|
|
17
17
|
span.add_field "request.method", env.method.upcase
|
18
|
-
span.add_field "request.
|
18
|
+
span.add_field "request.scheme", env.url.scheme
|
19
19
|
span.add_field "request.host", env.url.host
|
20
20
|
span.add_field "request.path", env.url.path
|
21
21
|
span.add_field "meta.type", "http_client"
|
@@ -13,8 +13,10 @@ module Honeycomb
|
|
13
13
|
["HTTP_VERSION", "request.http_version"],
|
14
14
|
["HTTP_HOST", "request.host"],
|
15
15
|
["REMOTE_ADDR", "request.remote_addr"],
|
16
|
+
["HTTP_ACCEPT", "request.header.accept"],
|
17
|
+
["CONTENT_TYPE", "request.header.content_type"],
|
16
18
|
["HTTP_USER_AGENT", "request.header.user_agent"],
|
17
|
-
["rack.url_scheme", "request.
|
19
|
+
["rack.url_scheme", "request.scheme"],
|
18
20
|
].freeze
|
19
21
|
|
20
22
|
attr_reader :app, :client
|
@@ -25,6 +27,7 @@ module Honeycomb
|
|
25
27
|
end
|
26
28
|
|
27
29
|
def call(env)
|
30
|
+
req = ::Rack::Request.new(env)
|
28
31
|
hny = env["HTTP_X_HONEYCOMB_TRACE"]
|
29
32
|
client.start_span(name: "http_request", serialized_trace: hny) do |span|
|
30
33
|
add_field = lambda do |key, value|
|
@@ -35,6 +38,9 @@ module Honeycomb
|
|
35
38
|
|
36
39
|
extract_fields(env, RACK_FIELDS, &add_field)
|
37
40
|
|
41
|
+
span.add_field("request.secure", req.ssl?)
|
42
|
+
span.add_field("request.xhr", req.xhr?)
|
43
|
+
|
38
44
|
status, headers, body = app.call(env)
|
39
45
|
|
40
46
|
add_package_information(env, &add_field)
|
@@ -42,6 +48,7 @@ module Honeycomb
|
|
42
48
|
extract_user_information(env, &add_field)
|
43
49
|
|
44
50
|
span.add_field("response.status_code", status)
|
51
|
+
span.add_field("response.content_type", headers["Content-Type"])
|
45
52
|
|
46
53
|
[status, headers, body]
|
47
54
|
end
|
@@ -11,29 +11,79 @@ module Honeycomb
|
|
11
11
|
yield "meta.package", "rails"
|
12
12
|
yield "meta.package_version", ::Rails::VERSION::STRING
|
13
13
|
|
14
|
-
::ActionDispatch::Request.new(env)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
found_route = true
|
32
|
-
yield "request.route", "#{env['REQUEST_METHOD']} #{route.path.spec}"
|
33
|
-
end
|
14
|
+
request = ::ActionDispatch::Request.new(env)
|
15
|
+
|
16
|
+
yield "request.controller", request.path_parameters[:controller]
|
17
|
+
yield "request.action", request.path_parameters[:action]
|
18
|
+
yield "request.route", route_for(request)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def route_for(request)
|
24
|
+
router = router_for(request)
|
25
|
+
routing = routing_for(request)
|
26
|
+
|
27
|
+
return unless router && routing
|
28
|
+
|
29
|
+
router.recognize(routing) do |route, _|
|
30
|
+
return "#{request.method} #{route.path.spec}"
|
34
31
|
end
|
35
32
|
end
|
36
33
|
|
34
|
+
# Broadly compatible way of getting the ActionDispatch::Routing::RouteSet.
|
35
|
+
#
|
36
|
+
# While we'd like to just use ActionDispatch::Request#routes, that method
|
37
|
+
# was only added circa Rails 5. To support Rails 4, we have to use direct
|
38
|
+
# Rack env access.
|
39
|
+
#
|
40
|
+
# @see https://github.com/rails/rails/commit/87a75910640b83a677099198ccb3317d9850c204
|
41
|
+
def router_for(request)
|
42
|
+
routes = request.env["action_dispatch.routes"]
|
43
|
+
routes.router if routes.respond_to?(:router)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Constructs a simplified ActionDispatch::Request with the original route.
|
47
|
+
#
|
48
|
+
# This is based on ActionDispatch::Routing::RouteSet#recognize_path, which
|
49
|
+
# reconstructs an ActionDispatch::Request using a given HTTP method + path
|
50
|
+
# by making a mock Rack environment. Here, instead of taking the method +
|
51
|
+
# path from input parameters, we use the original values from the actual
|
52
|
+
# incoming request (prior to any mangling that may have been done by
|
53
|
+
# middleware).
|
54
|
+
#
|
55
|
+
# The resulting ActionDispatch::Request instance is suitable for passing to
|
56
|
+
# ActionDispatch::Journey::Router#recognize to get the original Rails
|
57
|
+
# routing information corresponding to the incoming request.
|
58
|
+
#
|
59
|
+
# @param request [ActionDispatch::Request]
|
60
|
+
# the actual incoming Rails request
|
61
|
+
#
|
62
|
+
# @return [ActionDispatch::Request]
|
63
|
+
# a simplified version of the incoming request that retains the original
|
64
|
+
# routing information, but nothing else (e.g., no HTTP parameters)
|
65
|
+
#
|
66
|
+
# @return [nil]
|
67
|
+
# if the original request's path is invalid
|
68
|
+
#
|
69
|
+
# @see https://api.rubyonrails.org/classes/ActionDispatch/Request.html#method-i-method
|
70
|
+
# @see https://api.rubyonrails.org/classes/ActionDispatch/Request.html#method-i-original_fullpath
|
71
|
+
# @see https://github.com/rails/rails/blob/2a44ff12c858d296797963f7aa97abfa0c840a15/actionpack/lib/action_dispatch/journey/router/utils.rb#L7-L27
|
72
|
+
# @see https://github.com/rails/rails/blob/2a44ff12c858d296797963f7aa97abfa0c840a15/actionpack/lib/action_dispatch/routing/route_set.rb#L846-L859
|
73
|
+
def routing_for(request)
|
74
|
+
verb = request.method
|
75
|
+
path = request.original_fullpath
|
76
|
+
path = normalize(path) unless path =~ %r{://}
|
77
|
+
env = ::Rack::MockRequest.env_for(path, method: verb)
|
78
|
+
::ActionDispatch::Request.new(env)
|
79
|
+
rescue URI::InvalidURIError
|
80
|
+
nil
|
81
|
+
end
|
82
|
+
|
83
|
+
def normalize(path)
|
84
|
+
::ActionDispatch::Journey::Router::Utils.normalize_path(path)
|
85
|
+
end
|
86
|
+
|
37
87
|
# Rails middleware
|
38
88
|
class Middleware
|
39
89
|
include Rack
|
@@ -9,9 +9,8 @@ module Honeycomb
|
|
9
9
|
initializer("honeycomb.install_middleware",
|
10
10
|
after: :load_config_initializers) do |app|
|
11
11
|
if Honeycomb.client
|
12
|
-
|
13
|
-
|
14
|
-
::Rails::Rack::Logger,
|
12
|
+
app.config.middleware.insert_after(
|
13
|
+
ActionDispatch::ShowExceptions,
|
15
14
|
Honeycomb::Rails::Middleware,
|
16
15
|
client: Honeycomb.client,
|
17
16
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: honeycomb-beeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Holman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libhoney
|
@@ -16,14 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.14'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.14.2
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
29
|
+
version: '1.14'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.14.2
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: appraisal
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|