honeycomb-beeline 2.4.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/bundler_version.sh +4 -0
- data/.circleci/config.yml +50 -33
- data/.github/CODEOWNERS +1 -1
- data/.github/dependabot.yml +15 -0
- data/.github/workflows/add-to-project.yml +14 -0
- data/.github/workflows/apply-labels.yml +10 -0
- data/.gitignore +1 -0
- data/.rspec +4 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +40 -0
- data/Gemfile.lock +10 -5
- data/honeycomb-beeline.gemspec +1 -0
- data/lib/honeycomb/beeline/version.rb +1 -1
- data/lib/honeycomb/client.rb +38 -13
- data/lib/honeycomb/configuration.rb +6 -0
- data/lib/honeycomb/integrations/active_support.rb +22 -9
- data/lib/honeycomb/integrations/rack.rb +12 -5
- data/lib/honeycomb/integrations/rails.rb +10 -0
- data/lib/honeycomb/integrations/redis.rb +103 -94
- metadata +21 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ae074f65cd2b6319b74e07b06148e9e2cd446bfd3fc7c2c686c9ab4702550a4
|
4
|
+
data.tar.gz: a7c934d59de13e4099636470fb9660520478bbe56c38c5eb42c69839cb6a6f4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12c63d47f117a7fae5771b504ff58191627824618c7127257ca29f9c0e1de9cee3e140184bf3e04935846a2a9cef6768245ce6a89d540a1e48b8ddd1eb923704
|
7
|
+
data.tar.gz: 599d93dc3ca17e34b4828cf557aa98a4b697a26cfffa8957a4b25997c37d7967ab2753bcc01ced943db8e74a52f6dff0f93c0a51ee59d28b0fbc9ad1f144a30b
|
@@ -3,6 +3,10 @@
|
|
3
3
|
set -ux
|
4
4
|
|
5
5
|
if [[ "$BUNDLE_GEMFILE" =~ (rails_41.gemfile|rails_42.gemfile)$ ]]; then
|
6
|
+
echo "Rails 4.1 and 4.2 require an old Bundler"
|
6
7
|
gem uninstall -v '>= 2' -ax bundler
|
7
8
|
gem install bundler -v '< 2'
|
9
|
+
else
|
10
|
+
echo "Get the latest Bundler"
|
11
|
+
gem update bundler
|
8
12
|
fi
|
data/.circleci/config.yml
CHANGED
@@ -6,7 +6,6 @@ commands:
|
|
6
6
|
type: string
|
7
7
|
gemfile:
|
8
8
|
type: string
|
9
|
-
default: Gemfile
|
10
9
|
command:
|
11
10
|
type: string
|
12
11
|
default: bundle exec rake test
|
@@ -14,16 +13,19 @@ commands:
|
|
14
13
|
- checkout
|
15
14
|
- restore_cache:
|
16
15
|
keys:
|
17
|
-
- gems-v1-<< parameters.ruby-version >>-{{ checksum "Gemfile.lock" }}
|
16
|
+
- gems-v1-<< parameters.ruby-version >>-<< parameters.gemfile >>-{{ checksum "Gemfile.lock" }}
|
17
|
+
- gems-v1-<< parameters.ruby-version >>-<< parameters.gemfile >>
|
18
18
|
- gems-v1-<< parameters.ruby-version >>
|
19
|
-
- run:
|
20
|
-
- run:
|
21
|
-
- run:
|
19
|
+
- run: .circleci/bundler_version.sh
|
20
|
+
- run: bundle config set --local path $HOME/project/vendor/bundle
|
21
|
+
- run: bundle install --jobs=4 --retry=3
|
22
|
+
- run: bundle clean --force
|
23
|
+
- run: bundle env
|
22
24
|
- save_cache:
|
23
25
|
paths:
|
24
26
|
- ./vendor/bundle
|
25
|
-
key: gems-v1-<< parameters.ruby-version >>-{{ checksum "Gemfile.lock" }}
|
26
|
-
- run:
|
27
|
+
key: gems-v1-<< parameters.ruby-version >>-<< parameters.gemfile >>-{{ checksum "Gemfile.lock" }}
|
28
|
+
- run: << parameters.command >>
|
27
29
|
|
28
30
|
jobs:
|
29
31
|
build_artifacts:
|
@@ -80,9 +82,12 @@ jobs:
|
|
80
82
|
default: "2.6"
|
81
83
|
docker:
|
82
84
|
- image: circleci/ruby:<< parameters.ruby-version >>
|
85
|
+
environment:
|
86
|
+
BUNDLE_GEMFILE: ./Gemfile
|
83
87
|
steps:
|
84
88
|
- ruby:
|
85
89
|
ruby-version: << parameters.ruby-version >>
|
90
|
+
gemfile: root
|
86
91
|
command: bundle exec rake rubocop
|
87
92
|
test:
|
88
93
|
parameters:
|
@@ -92,11 +97,15 @@ jobs:
|
|
92
97
|
type: string
|
93
98
|
docker:
|
94
99
|
- image: circleci/ruby:<< parameters.ruby-version >>
|
100
|
+
environment:
|
101
|
+
BUNDLE_GEMFILE: gemfiles/<< parameters.gemfile >>.gemfile
|
95
102
|
steps:
|
96
103
|
- ruby:
|
97
104
|
ruby-version: << parameters.ruby-version >>
|
98
105
|
gemfile: << parameters.gemfile >>
|
99
106
|
command: bundle exec rake test
|
107
|
+
- store_test_results:
|
108
|
+
path: test/reports
|
100
109
|
|
101
110
|
workflows:
|
102
111
|
nightly:
|
@@ -110,49 +119,57 @@ workflows:
|
|
110
119
|
jobs:
|
111
120
|
- lint
|
112
121
|
- test: &test
|
122
|
+
name: test-<< matrix.gemfile >>-ruby_<< matrix.ruby-version >>
|
113
123
|
requires:
|
114
124
|
- lint
|
115
125
|
matrix:
|
116
126
|
parameters:
|
117
127
|
ruby-version: ["2.2", "2.3", "2.4", "2.5", "2.6", "2.7"]
|
118
128
|
gemfile:
|
119
|
-
-
|
120
|
-
-
|
121
|
-
-
|
122
|
-
-
|
123
|
-
-
|
124
|
-
-
|
125
|
-
-
|
126
|
-
-
|
127
|
-
-
|
128
|
-
-
|
129
|
-
-
|
130
|
-
-
|
131
|
-
-
|
132
|
-
-
|
133
|
-
-
|
134
|
-
-
|
129
|
+
- aws_2
|
130
|
+
- aws_3
|
131
|
+
- faraday_0
|
132
|
+
- faraday_1
|
133
|
+
- sequel4
|
134
|
+
- sequel5
|
135
|
+
- sinatra
|
136
|
+
- rack
|
137
|
+
- rails_41
|
138
|
+
- rails_42
|
139
|
+
- rails_5
|
140
|
+
- rails_51
|
141
|
+
- rails_52
|
142
|
+
- rails_6
|
143
|
+
- rails_61
|
144
|
+
- redis_3
|
145
|
+
- redis_4
|
135
146
|
exclude:
|
136
147
|
- ruby-version: "2.2"
|
137
|
-
gemfile:
|
148
|
+
gemfile: faraday_1
|
138
149
|
- ruby-version: "2.2"
|
139
|
-
gemfile:
|
150
|
+
gemfile: rails_52
|
140
151
|
- ruby-version: "2.2"
|
141
|
-
gemfile:
|
152
|
+
gemfile: rails_6
|
142
153
|
- ruby-version: "2.3"
|
143
|
-
gemfile:
|
154
|
+
gemfile: rails_6
|
144
155
|
- ruby-version: "2.4"
|
145
|
-
gemfile:
|
156
|
+
gemfile: rails_6
|
157
|
+
- ruby-version: "2.2"
|
158
|
+
gemfile: rails_61
|
159
|
+
- ruby-version: "2.3"
|
160
|
+
gemfile: rails_61
|
161
|
+
- ruby-version: "2.4"
|
162
|
+
gemfile: rails_61
|
146
163
|
- ruby-version: "2.4"
|
147
|
-
gemfile:
|
164
|
+
gemfile: rails_41
|
148
165
|
- ruby-version: "2.5"
|
149
|
-
gemfile:
|
166
|
+
gemfile: rails_41
|
150
167
|
- ruby-version: "2.6"
|
151
|
-
gemfile:
|
168
|
+
gemfile: rails_41
|
152
169
|
- ruby-version: "2.7"
|
153
|
-
gemfile:
|
170
|
+
gemfile: rails_41
|
154
171
|
- ruby-version: "2.7"
|
155
|
-
gemfile:
|
172
|
+
gemfile: rails_42
|
156
173
|
beeline:
|
157
174
|
jobs:
|
158
175
|
- lint:
|
data/.github/CODEOWNERS
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
3
|
+
# Please see the documentation for all configuration options:
|
4
|
+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
5
|
+
|
6
|
+
version: 2
|
7
|
+
updates:
|
8
|
+
- package-ecosystem: "bundler" # See documentation for possible values
|
9
|
+
directory: "/gemfiles/" # Location of package manifests
|
10
|
+
schedule:
|
11
|
+
interval: "weekly"
|
12
|
+
labels:
|
13
|
+
- "type: dependencies"
|
14
|
+
reviewers:
|
15
|
+
- "honeycombio/telemetry-team"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
name: Apply project management flow
|
2
|
+
on:
|
3
|
+
issues:
|
4
|
+
types: [opened]
|
5
|
+
pull_request_target:
|
6
|
+
types: [opened]
|
7
|
+
jobs:
|
8
|
+
project-management:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
name: Apply project management flow
|
11
|
+
steps:
|
12
|
+
- uses: honeycombio/oss-management-actions/projects@v1
|
13
|
+
with:
|
14
|
+
ghprojects-token: ${{ secrets.GHPROJECTS_TOKEN }}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
name: Apply project labels
|
2
|
+
on: [issues, pull_request, label]
|
3
|
+
jobs:
|
4
|
+
apply-labels:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
name: Apply common project labels
|
7
|
+
steps:
|
8
|
+
- uses: honeycombio/oss-management-actions/labels@v1
|
9
|
+
with:
|
10
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.7.2
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,45 @@
|
|
1
1
|
# beeline-ruby changelog
|
2
2
|
|
3
|
+
## 2.6.0 2021-07-23
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- Allow setting different notification handling logic for specific events (#152) | [@lirossarvet](https://github.com/lirossarvet)
|
8
|
+
|
9
|
+
## 2.5.0 2021-07-16
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Allow backtrace to be sent with errors (#160) | [@lirossarvet](https://github.com/lirossarvet)
|
14
|
+
|
15
|
+
### Maintenance
|
16
|
+
|
17
|
+
- Updates Github Action Workflows (#159) | [@bdarfler](https://github.com/bdarfler)
|
18
|
+
- Adds dependabot label (#158) | [@bdarfler](https://github.com/bdarfler)
|
19
|
+
- Switches CODEOWNERS to telemetry-team (#157) | [@bdarfler](https://github.com/bdarfler)
|
20
|
+
|
21
|
+
## 2.4.2 2021-06-25
|
22
|
+
|
23
|
+
### Fixes
|
24
|
+
|
25
|
+
- Update Rails middleware to get status code even on raised error. (#153) [@lirossarvet](https://github.com/lirossarvet)
|
26
|
+
- Make Rails spec consistent with Honeycomb Railtie Initialization. (#154) [@robbkidd](https://github.com/robbkidd)
|
27
|
+
- CI Improvements (#155) [@robbkidd](https://github.com/robbkidd)
|
28
|
+
- Improve performance of Redis command serialization. (#146) [@ajvondrak](https://github.com/ajvondrak)
|
29
|
+
|
30
|
+
## 2.4.1 2021-06-01
|
31
|
+
|
32
|
+
### Fixes
|
33
|
+
|
34
|
+
- Updates Redis event-field filter to handle string keys in options in
|
35
|
+
addition to symbol keys. (#147) [@cupakromer](https://github.com/cupakromer)
|
36
|
+
|
37
|
+
### Maintenance
|
38
|
+
|
39
|
+
- Expanded on the Rails 5.2 example. (#141) [@robbkidd](https://github.com/robbkidd)
|
40
|
+
- Added a test case for current behavior of event emitted for an
|
41
|
+
exception raised in Rails. (@132) [@vreynolds](https://github.com/vreynolds)
|
42
|
+
|
3
43
|
## 2.4.0 2021-01-07
|
4
44
|
### Added
|
5
45
|
- Add support for HTTP Accept-Encoding header (#125) [@irvingreid](https://github.com/irvingreid)
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
honeycomb-beeline (2.
|
4
|
+
honeycomb-beeline (2.6.0)
|
5
5
|
libhoney (~> 1.14, >= 1.14.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -29,6 +29,7 @@ GEM
|
|
29
29
|
docile (1.3.2)
|
30
30
|
domain_name (0.5.20190701)
|
31
31
|
unf (>= 0.0.5, < 1.0.0)
|
32
|
+
excon (0.82.0)
|
32
33
|
ffi (1.12.2)
|
33
34
|
ffi-compiler (1.0.1)
|
34
35
|
ffi (>= 1.0.0)
|
@@ -39,16 +40,17 @@ GEM
|
|
39
40
|
http-cookie (~> 1.0)
|
40
41
|
http-form_data (~> 2.2)
|
41
42
|
http-parser (~> 1.2.0)
|
42
|
-
http-cookie (1.0.
|
43
|
+
http-cookie (1.0.4)
|
43
44
|
domain_name (~> 0.5)
|
44
45
|
http-form_data (2.3.0)
|
45
|
-
http-parser (1.2.
|
46
|
+
http-parser (1.2.3)
|
46
47
|
ffi-compiler (>= 1.0, < 2.0)
|
47
48
|
iniparse (1.5.0)
|
48
49
|
jaro_winkler (1.5.4)
|
49
50
|
json (2.3.1)
|
50
|
-
libhoney (1.
|
51
|
+
libhoney (1.18.0)
|
51
52
|
addressable (~> 2.0)
|
53
|
+
excon
|
52
54
|
http (>= 2.0, < 5.0)
|
53
55
|
method_source (0.9.2)
|
54
56
|
overcommit (0.46.0)
|
@@ -79,6 +81,8 @@ GEM
|
|
79
81
|
diff-lcs (>= 1.2.0, < 2.0)
|
80
82
|
rspec-support (~> 3.9.0)
|
81
83
|
rspec-support (3.9.3)
|
84
|
+
rspec_junit_formatter (0.4.1)
|
85
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
82
86
|
rubocop (0.68.1)
|
83
87
|
jaro_winkler (~> 1.5.1)
|
84
88
|
parallel (~> 1.10)
|
@@ -124,6 +128,7 @@ DEPENDENCIES
|
|
124
128
|
pry-byebug (~> 3.6.0)
|
125
129
|
rake
|
126
130
|
rspec (~> 3.0)
|
131
|
+
rspec_junit_formatter
|
127
132
|
rubocop (< 0.69)
|
128
133
|
rubocop-performance (< 1.3.0)
|
129
134
|
simplecov
|
@@ -131,4 +136,4 @@ DEPENDENCIES
|
|
131
136
|
webmock
|
132
137
|
|
133
138
|
BUNDLED WITH
|
134
|
-
2.
|
139
|
+
2.2.21
|
data/honeycomb-beeline.gemspec
CHANGED
@@ -48,6 +48,7 @@ Gem::Specification.new do |spec|
|
|
48
48
|
spec.add_development_dependency "pry-byebug", "~> 3.6.0"
|
49
49
|
spec.add_development_dependency "rake"
|
50
50
|
spec.add_development_dependency "rspec", "~> 3.0"
|
51
|
+
spec.add_development_dependency "rspec_junit_formatter"
|
51
52
|
spec.add_development_dependency "rubocop", "< 0.69"
|
52
53
|
spec.add_development_dependency "rubocop-performance", "< 1.3.0"
|
53
54
|
spec.add_development_dependency "simplecov"
|
data/lib/honeycomb/client.rb
CHANGED
@@ -38,6 +38,7 @@ module Honeycomb
|
|
38
38
|
parser_hook: configuration.http_trace_parser_hook,
|
39
39
|
propagation_hook: configuration.http_trace_propagation_hook,
|
40
40
|
}
|
41
|
+
@error_backtrace_limit = configuration.error_backtrace_limit.to_i
|
41
42
|
|
42
43
|
configuration.after_initialize(self)
|
43
44
|
|
@@ -47,16 +48,7 @@ module Honeycomb
|
|
47
48
|
end
|
48
49
|
|
49
50
|
def start_span(name:, serialized_trace: nil, **fields)
|
50
|
-
|
51
|
-
Trace.new(serialized_trace: serialized_trace,
|
52
|
-
builder: libhoney.builder,
|
53
|
-
context: context,
|
54
|
-
**@additional_trace_options)
|
55
|
-
else
|
56
|
-
context.current_span.create_child
|
57
|
-
end
|
58
|
-
|
59
|
-
current_span = context.current_span
|
51
|
+
current_span = new_span_for_context(serialized_trace: serialized_trace)
|
60
52
|
|
61
53
|
fields.each do |key, value|
|
62
54
|
current_span.add_field(key, value)
|
@@ -69,8 +61,8 @@ module Honeycomb
|
|
69
61
|
begin
|
70
62
|
yield current_span
|
71
63
|
rescue StandardError => e
|
72
|
-
current_span
|
73
|
-
|
64
|
+
add_exception_data(current_span, e)
|
65
|
+
|
74
66
|
raise e
|
75
67
|
ensure
|
76
68
|
current_span.send
|
@@ -99,6 +91,39 @@ module Honeycomb
|
|
99
91
|
|
100
92
|
private
|
101
93
|
|
102
|
-
attr_reader :context
|
94
|
+
attr_reader :context, :error_backtrace_limit
|
95
|
+
|
96
|
+
def new_span_for_context(serialized_trace:)
|
97
|
+
if context.current_trace.nil?
|
98
|
+
Trace.new(
|
99
|
+
serialized_trace: serialized_trace,
|
100
|
+
builder: libhoney.builder,
|
101
|
+
context: context,
|
102
|
+
**@additional_trace_options,
|
103
|
+
)
|
104
|
+
else
|
105
|
+
context.current_span.create_child
|
106
|
+
end
|
107
|
+
|
108
|
+
context.current_span
|
109
|
+
end
|
110
|
+
|
111
|
+
def add_exception_data(span, exception)
|
112
|
+
span.add_field("error", exception.class.name)
|
113
|
+
span.add_field("error_detail", exception.message)
|
114
|
+
|
115
|
+
return if error_backtrace_limit <= 0
|
116
|
+
|
117
|
+
span.add_field(
|
118
|
+
"error_backtrace",
|
119
|
+
exception
|
120
|
+
.backtrace
|
121
|
+
.take(error_backtrace_limit)
|
122
|
+
.join("\n")
|
123
|
+
.encode("UTF-8", invalid: :replace, undef: :replace, replace: "�"),
|
124
|
+
)
|
125
|
+
span.add_field("error_backtrace_limit", error_backtrace_limit)
|
126
|
+
span.add_field("error_backtrace_total_length", exception.backtrace.length)
|
127
|
+
end
|
103
128
|
end
|
104
129
|
end
|
@@ -12,12 +12,14 @@ module Honeycomb
|
|
12
12
|
:debug
|
13
13
|
|
14
14
|
attr_writer :service_name, :client, :host_name
|
15
|
+
attr_reader :error_backtrace_limit
|
15
16
|
|
16
17
|
def initialize
|
17
18
|
@write_key = ENV["HONEYCOMB_WRITEKEY"]
|
18
19
|
@dataset = ENV["HONEYCOMB_DATASET"]
|
19
20
|
@service_name = ENV["HONEYCOMB_SERVICE"]
|
20
21
|
@debug = ENV.key?("HONEYCOMB_DEBUG")
|
22
|
+
@error_backtrace_limit = 0
|
21
23
|
@client = nil
|
22
24
|
end
|
23
25
|
|
@@ -25,6 +27,10 @@ module Honeycomb
|
|
25
27
|
@service_name || dataset
|
26
28
|
end
|
27
29
|
|
30
|
+
def error_backtrace_limit=(val)
|
31
|
+
@error_backtrace_limit = Integer(val)
|
32
|
+
end
|
33
|
+
|
28
34
|
def client
|
29
35
|
options = {}.tap do |o|
|
30
36
|
o[:writekey] = write_key
|
@@ -8,12 +8,13 @@ module Honeycomb
|
|
8
8
|
# Included in the configuration object to specify events that should be
|
9
9
|
# subscribed to
|
10
10
|
module Configuration
|
11
|
-
|
11
|
+
attr_writer :notification_events
|
12
12
|
|
13
13
|
def after_initialize(client)
|
14
14
|
super(client) if defined?(super)
|
15
15
|
|
16
|
-
events = notification_events
|
16
|
+
events = notification_events | active_support_handlers.keys
|
17
|
+
|
17
18
|
ActiveSupport::Subscriber.new(client: client).tap do |sub|
|
18
19
|
events.each do |event|
|
19
20
|
sub.subscribe(event, &method(:handle_notification_event))
|
@@ -21,18 +22,30 @@ module Honeycomb
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
|
-
def on_notification_event(&hook)
|
25
|
-
if
|
26
|
-
|
25
|
+
def on_notification_event(event_name = nil, &hook)
|
26
|
+
if event_name
|
27
|
+
active_support_handlers[event_name] = hook
|
27
28
|
else
|
28
|
-
@
|
29
|
+
@default_handler = hook
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
33
|
def handle_notification_event(name, span, payload)
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
handler = active_support_handlers.fetch(name, default_handler)
|
35
|
+
|
36
|
+
handler.call(name, span, payload)
|
37
|
+
end
|
38
|
+
|
39
|
+
def active_support_handlers
|
40
|
+
@active_support_handlers ||= {}
|
41
|
+
end
|
42
|
+
|
43
|
+
def notification_events
|
44
|
+
@notification_events ||= []
|
45
|
+
end
|
46
|
+
|
47
|
+
def default_handler
|
48
|
+
@default_handler ||= lambda do |name, span, payload|
|
36
49
|
payload.each do |key, value|
|
37
50
|
# Make ActionController::Parameters parseable by libhoney.
|
38
51
|
value = value.to_unsafe_hash if value.respond_to?(:to_unsafe_hash)
|
@@ -48,11 +48,12 @@ module Honeycomb
|
|
48
48
|
span.add_field("request.secure", req.ssl?)
|
49
49
|
span.add_field("request.xhr", req.xhr?)
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
begin
|
52
|
+
status, headers, body = call_with_hook(env, span, &add_field)
|
53
|
+
ensure
|
54
|
+
add_package_information(env, &add_field)
|
55
|
+
extract_user_information(env, &add_field)
|
56
|
+
end
|
56
57
|
|
57
58
|
span.add_field("response.status_code", status)
|
58
59
|
span.add_field("response.content_type", headers["Content-Type"])
|
@@ -72,6 +73,12 @@ module Honeycomb
|
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
76
|
+
private
|
77
|
+
|
78
|
+
def call_with_hook(env, _span, &_add_field)
|
79
|
+
app.call(env)
|
80
|
+
end
|
81
|
+
|
75
82
|
# Rack middleware
|
76
83
|
class Middleware
|
77
84
|
include Rack
|
@@ -89,6 +89,16 @@ module Honeycomb
|
|
89
89
|
include Rack
|
90
90
|
include Warden
|
91
91
|
include Rails
|
92
|
+
|
93
|
+
def call_with_hook(env, span, &_add_field)
|
94
|
+
super
|
95
|
+
rescue StandardError => e
|
96
|
+
wrapped = ActionDispatch::ExceptionWrapper.new(nil, e)
|
97
|
+
|
98
|
+
span.add_field "response.status_code", wrapped.status_code
|
99
|
+
|
100
|
+
raise e
|
101
|
+
end
|
92
102
|
end
|
93
103
|
end
|
94
104
|
end
|
@@ -159,7 +159,17 @@ module Honeycomb
|
|
159
159
|
# * :logger - just some Ruby object, not useful
|
160
160
|
# * :_parsed - implementation detail
|
161
161
|
def ignore?(option)
|
162
|
-
|
162
|
+
# Redis options may be symbol or string keys.
|
163
|
+
#
|
164
|
+
# This normalizes `option` using `to_sym` as benchmarking on Ruby MRI
|
165
|
+
# v2.6.6 and v2.7.3 has shown that was faster compared to `to_s`.
|
166
|
+
# However, `nil` does not support `to_sym`. This uses a guard clause to
|
167
|
+
# handle the `nil` case because this is still faster than safe
|
168
|
+
# navigation. Also this lib still supports Ruby 2.2.0; which does not
|
169
|
+
# include safe navigation.
|
170
|
+
return true unless option
|
171
|
+
|
172
|
+
%i[url password logger _parsed].include?(option.to_sym)
|
163
173
|
end
|
164
174
|
|
165
175
|
def format(cmd)
|
@@ -177,16 +187,6 @@ module Honeycomb
|
|
177
187
|
args.map! { "[sanitized]" }
|
178
188
|
end
|
179
189
|
|
180
|
-
def prettify(arg)
|
181
|
-
quotes = false
|
182
|
-
pretty = "".dup
|
183
|
-
arg.to_s.each_char do |c|
|
184
|
-
quotes ||= needs_quotes?(c)
|
185
|
-
pretty << escape(c)
|
186
|
-
end
|
187
|
-
quotes ? "\"#{pretty}\"" : pretty
|
188
|
-
end
|
189
|
-
|
190
190
|
# This aims to replicate the algorithms used by redis-cli.
|
191
191
|
#
|
192
192
|
# @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L940-L1067
|
@@ -194,54 +194,15 @@ module Honeycomb
|
|
194
194
|
#
|
195
195
|
# @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L878-L907
|
196
196
|
# The redis-cli printing algorithm
|
197
|
-
def
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
# A lookup table for backslash-escaped characters.
|
205
|
-
#
|
206
|
-
# This is used by {#escape_with_backslash?} and {#escape_with_backslash}
|
207
|
-
# to replicate the hard-coded `case` statements in redis-cli. As of this
|
208
|
-
# writing, Redis recognizes a handful of standard C escape sequences,
|
209
|
-
# like "\n" for newlines.
|
210
|
-
#
|
211
|
-
# Because {#prettify} will output double quoted strings if any escaping
|
212
|
-
# is needed, this table must additionally consider the double-quote to be
|
213
|
-
# a backslash-escaped character. For example, instead of generating
|
214
|
-
#
|
215
|
-
# '"hello"'
|
216
|
-
#
|
217
|
-
# we'll generate
|
218
|
-
#
|
219
|
-
# "\"hello\""
|
220
|
-
#
|
221
|
-
# even though redis-cli would technically recognize the single-quoted
|
222
|
-
# version.
|
223
|
-
#
|
224
|
-
# @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L888-L896
|
225
|
-
# The redis-cli algorithm for outputting standard escape sequences
|
226
|
-
BACKSLASHES = {
|
227
|
-
"\\" => "\\\\",
|
228
|
-
'"' => '\\"',
|
229
|
-
"\n" => "\\n",
|
230
|
-
"\r" => "\\r",
|
231
|
-
"\t" => "\\t",
|
232
|
-
"\a" => "\\a",
|
233
|
-
"\b" => "\\b",
|
234
|
-
}.freeze
|
235
|
-
|
236
|
-
def escape_with_backslash?(char)
|
237
|
-
BACKSLASHES.key?(char)
|
238
|
-
end
|
239
|
-
|
240
|
-
def escape_with_backslash(char)
|
241
|
-
BACKSLASHES.fetch(char, char)
|
197
|
+
def prettify(arg)
|
198
|
+
pretty = arg.to_s.dup
|
199
|
+
pretty.encode!("UTF-8", "binary", fallback: ->(c) { hex(c) })
|
200
|
+
pretty.gsub!(NEEDS_BACKSLASH, BACKSLASH)
|
201
|
+
pretty.gsub!(NEEDS_HEX) { |c| hex(c) }
|
202
|
+
pretty =~ NEEDS_QUOTES ? "\"#{pretty}\"" : pretty
|
242
203
|
end
|
243
204
|
|
244
|
-
#
|
205
|
+
# A regular expression matching characters that need to be hex-encoded.
|
245
206
|
#
|
246
207
|
# This replicates the C isprint() function that redis-cli uses to decide
|
247
208
|
# whether to escape a character in hexadecimal notation, "\xhh". Any
|
@@ -277,18 +238,95 @@ module Honeycomb
|
|
277
238
|
# escape it.
|
278
239
|
#
|
279
240
|
# What's more, Ruby's Regexp#=~ method will blow up if the string does
|
280
|
-
# not have a valid encoding (e.g., in UTF-8).
|
281
|
-
#
|
282
|
-
# invalid
|
283
|
-
# invalidly-encoded characters before testing the above match.
|
241
|
+
# not have a valid encoding (e.g., in UTF-8). We handle this case
|
242
|
+
# separately, though, using String#encode! with a :fallback option to
|
243
|
+
# hex-encode invalid UTF-8 byte sequences with {#hex}.
|
284
244
|
#
|
285
245
|
# @see https://ruby-doc.org/core-2.6.5/Regexp.html
|
286
246
|
# @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L878-L880
|
287
247
|
# @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L898-L901
|
288
248
|
# @see https://www.justinweiss.com/articles/3-steps-to-fix-encoding-problems-in-ruby/
|
289
|
-
|
290
|
-
|
291
|
-
|
249
|
+
NEEDS_HEX = /[^[:print:]&&[:ascii:]]/.freeze
|
250
|
+
|
251
|
+
# A regular expression for characters that need to be backslash-escaped.
|
252
|
+
#
|
253
|
+
# Any match of this regexp will be substituted according to the
|
254
|
+
# {BACKSLASH} table. This includes standard C escape sequences (newlines,
|
255
|
+
# tabs, etc) as well as a couple special considerations:
|
256
|
+
#
|
257
|
+
# 1. Because {#prettify} will output double quoted strings if any
|
258
|
+
# escaping is needed, we must match double quotes (") so they'll be
|
259
|
+
# replaced by escaped quotes (\").
|
260
|
+
#
|
261
|
+
# 2. Backslashes themselves get backslash-escaped, so \ becomes \\.
|
262
|
+
# However, strings with invalid UTF-8 encoding will blow up when we
|
263
|
+
# try to use String#gsub!, so {#prettify} must first use
|
264
|
+
# String#encode! to scrub out invalid characters. It does this by
|
265
|
+
# replacing invalid bytes with hex-encoded escape sequences using
|
266
|
+
# {#hex}. This will insert sequences like \xhh, which contains a
|
267
|
+
# backslash that we *don't* want to escape.
|
268
|
+
#
|
269
|
+
# Unfortunately, this regexp can't really distinguish between
|
270
|
+
# backslashes in the original input vs backslashes resulting from the
|
271
|
+
# UTF-8 fallback. We make an effort by using a negative lookahead.
|
272
|
+
# That way, only backslashes that *aren't* followed by x + hex digit +
|
273
|
+
# hex digit will be escaped.
|
274
|
+
NEEDS_BACKSLASH = /["\n\r\t\a\b]|\\(?!x\h\h)/.freeze
|
275
|
+
|
276
|
+
# A lookup table for backslash-escaped characters.
|
277
|
+
#
|
278
|
+
# This is used by {#prettify} to replicate the hard-coded `case`
|
279
|
+
# statements in redis-cli. As of this writing, Redis recognizes a handful
|
280
|
+
# of standard C escape sequences, like "\n" for newlines.
|
281
|
+
#
|
282
|
+
# Because {#prettify} will output double quoted strings if any escaping
|
283
|
+
# is needed, this table must additionally consider the double-quote to be
|
284
|
+
# a backslash-escaped character. For example, instead of generating
|
285
|
+
#
|
286
|
+
# '"hello"'
|
287
|
+
#
|
288
|
+
# we'll generate
|
289
|
+
#
|
290
|
+
# "\"hello\""
|
291
|
+
#
|
292
|
+
# even though redis-cli would technically recognize the single-quoted
|
293
|
+
# version.
|
294
|
+
#
|
295
|
+
# @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L888-L896
|
296
|
+
# The redis-cli algorithm for outputting standard escape sequences
|
297
|
+
BACKSLASH = {
|
298
|
+
"\\" => "\\\\",
|
299
|
+
'"' => '\\"',
|
300
|
+
"\n" => "\\n",
|
301
|
+
"\r" => "\\r",
|
302
|
+
"\t" => "\\t",
|
303
|
+
"\a" => "\\a",
|
304
|
+
"\b" => "\\b",
|
305
|
+
}.freeze
|
306
|
+
|
307
|
+
# If the final escaped string needs quotes, it will match this regexp.
|
308
|
+
#
|
309
|
+
# The overall string returned by {#prettify} should only be quoted if at
|
310
|
+
# least one of the following holds:
|
311
|
+
#
|
312
|
+
# 1. The string contains an escape sequence, broadly demarcated by a
|
313
|
+
# backslash. This includes standard escape sequences like "\n" and
|
314
|
+
# "\t" as well as hex-encoded bytes using the "\x" escape sequence.
|
315
|
+
# Since {#prettify} uses double quotes on its output string, we must
|
316
|
+
# also force quotes if the string itself contains a literal
|
317
|
+
# double quote. This double quote behavior is handled tacitly by the
|
318
|
+
# {NEEDS_BACKSLASH} + {BACKSLASH} replacement.
|
319
|
+
#
|
320
|
+
# 2. The string contains a single quote. Since redis-cli recognizes
|
321
|
+
# single-quoted strings, we want to wrap the {#prettify} output in
|
322
|
+
# double quotes so that the literal single quote character isn't
|
323
|
+
# mistaken as the delimiter of a new string.
|
324
|
+
#
|
325
|
+
# 3. The string contains any whitespace characters. If the {#prettify}
|
326
|
+
# output weren't wrapped in quotes, whitespace would act as a
|
327
|
+
# separator between arguments to the Redis command. To group things
|
328
|
+
# together, we need to quote the string.
|
329
|
+
NEEDS_QUOTES = /[\\'\s]/.freeze
|
292
330
|
|
293
331
|
# Hex-encodes a (presumably non-printable or non-ASCII) character.
|
294
332
|
#
|
@@ -316,38 +354,9 @@ module Honeycomb
|
|
316
354
|
# @see https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html
|
317
355
|
# @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L878-L880
|
318
356
|
# @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L898-L901
|
319
|
-
def
|
357
|
+
def hex(char)
|
320
358
|
char.bytes.map { |b| Kernel.format("\\x%02x", b) }.join
|
321
359
|
end
|
322
|
-
|
323
|
-
def escape?(char)
|
324
|
-
escape_with_backslash?(char) || escape_with_hex_codes?(char)
|
325
|
-
end
|
326
|
-
|
327
|
-
# Should this character cause {#prettify} to wrap its output in quotes?
|
328
|
-
#
|
329
|
-
# The overall string returned by {#prettify} should only be quoted if at
|
330
|
-
# least one of the following holds:
|
331
|
-
#
|
332
|
-
# 1. The string contains a character that needs to be escaped. This
|
333
|
-
# includes standard backslash escape sequences (like "\n" and "\t") as
|
334
|
-
# well as hex-encoded bytes using the "\x" escape sequence. Since
|
335
|
-
# {#prettify} uses double quotes on its output string, we must also
|
336
|
-
# force quotes if the string itself contains a literal double quote.
|
337
|
-
# This double quote behavior is handled tacitly by {BACKSLASHES}.
|
338
|
-
#
|
339
|
-
# 2. The string contains a single quote. Since redis-cli recognizes
|
340
|
-
# single-quoted strings, we want to wrap the {#prettify} output in
|
341
|
-
# double quotes so that the literal single quote character isn't
|
342
|
-
# mistaken as the delimiter of a new string.
|
343
|
-
#
|
344
|
-
# 3. The string contains any whitespace characters. If the {#prettify}
|
345
|
-
# output weren't wrapped in quotes, whitespace would act as a
|
346
|
-
# separator between arguments to the Redis command. To group things
|
347
|
-
# together, we need to quote the string.
|
348
|
-
def needs_quotes?(char)
|
349
|
-
escape?(char) || char == "'" || char =~ /\s/
|
350
|
-
end
|
351
360
|
end
|
352
361
|
end
|
353
362
|
end
|
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: 2.
|
4
|
+
version: 2.6.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: 2021-
|
11
|
+
date: 2021-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libhoney
|
@@ -156,6 +156,20 @@ dependencies:
|
|
156
156
|
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
version: '3.0'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: rspec_junit_formatter
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
159
173
|
- !ruby/object:Gem::Dependency
|
160
174
|
name: rubocop
|
161
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -238,11 +252,15 @@ files:
|
|
238
252
|
- ".circleci/setup-rubygems.sh"
|
239
253
|
- ".editorconfig"
|
240
254
|
- ".github/CODEOWNERS"
|
255
|
+
- ".github/dependabot.yml"
|
256
|
+
- ".github/workflows/add-to-project.yml"
|
257
|
+
- ".github/workflows/apply-labels.yml"
|
241
258
|
- ".gitignore"
|
242
259
|
- ".overcommit.yml"
|
243
260
|
- ".rspec"
|
244
261
|
- ".rubocop.yml"
|
245
262
|
- ".ruby-version"
|
263
|
+
- ".tool-versions"
|
246
264
|
- Appraisals
|
247
265
|
- CHANGELOG.md
|
248
266
|
- CODE_OF_CONDUCT.md
|
@@ -304,7 +322,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
304
322
|
- !ruby/object:Gem::Version
|
305
323
|
version: '0'
|
306
324
|
requirements: []
|
307
|
-
rubygems_version: 3.0.3
|
325
|
+
rubygems_version: 3.0.3.1
|
308
326
|
signing_key:
|
309
327
|
specification_version: 4
|
310
328
|
summary: Instrument your Ruby apps with Honeycomb
|