honeycomb-beeline 2.4.1 → 2.7.0

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: b0f7fd0a816bb7817900181d110a0f95d63b3191aeca362bbe0aadbc18609d7a
4
- data.tar.gz: '0702890fe4606c12f68ee032578a8b6f896fcc17c454794f23b3f0705a762c5a'
3
+ metadata.gz: 97016b5bcb57ce01fa980218fac7d8b71b3b145dec5ff30ad5ab9693d070d665
4
+ data.tar.gz: df32abbd87b653800ec3ebe2693cc3008593e307ee70ef1f5ab9333f139a96ba
5
5
  SHA512:
6
- metadata.gz: 96266118829b42c517e4a20e5d42b7d6bea65d8d5d65dd750c78d9825517070f7d1c15167c1dd6d5502be585c9621229369fa036e0c84fa8482cf109b91fcad7
7
- data.tar.gz: 9a9ced838db3c0b5948555042b80a1876270e36de75c69b490c8bf55c9150b32c59aa7d2db6e61bd845d131aa83e644e8116f12f8d266957b628a3672f79de54
6
+ metadata.gz: 51757f1553274cda4c354d16f50998745c41b0f89f4d27d763d8e81f2fe9142a1f491ea3208eb73d26211a81d5c2f2f15e282b9555fd4416d3a20f8cb3373f23
7
+ data.tar.gz: 0ef3666a518f2e965972967af8fb13d7597bd132026bc6ed8580b93458f0f1cf227a6ab05204dbc31f34da520f25e9f97201d3a9347173da4e7cdece0b6875b0
@@ -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: gem update bundler
20
- - run: BUNDLE_GEMFILE=<< parameters.gemfile >> ./.circleci/bundler_version.sh
21
- - run: BUNDLE_GEMFILE=<< parameters.gemfile >> bundle install --jobs=4 --retry=3 --path vendor/bundle
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: BUNDLE_GEMFILE=<< parameters.gemfile >> << parameters.command >>
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
- - gemfiles/aws_2.gemfile
120
- - gemfiles/aws_3.gemfile
121
- - gemfiles/faraday_0.gemfile
122
- - gemfiles/faraday_1.gemfile
123
- - gemfiles/sequel4.gemfile
124
- - gemfiles/sequel5.gemfile
125
- - gemfiles/sinatra.gemfile
126
- - gemfiles/rack.gemfile
127
- - gemfiles/rails_41.gemfile
128
- - gemfiles/rails_42.gemfile
129
- - gemfiles/rails_5.gemfile
130
- - gemfiles/rails_51.gemfile
131
- - gemfiles/rails_52.gemfile
132
- - gemfiles/rails_6.gemfile
133
- - gemfiles/redis_3.gemfile
134
- - gemfiles/redis_4.gemfile
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: gemfiles/faraday_1.gemfile
148
+ gemfile: faraday_1
138
149
  - ruby-version: "2.2"
139
- gemfile: gemfiles/rails_52.gemfile
150
+ gemfile: rails_52
140
151
  - ruby-version: "2.2"
141
- gemfile: gemfiles/rails_6.gemfile
152
+ gemfile: rails_6
142
153
  - ruby-version: "2.3"
143
- gemfile: gemfiles/rails_6.gemfile
154
+ gemfile: rails_6
144
155
  - ruby-version: "2.4"
145
- gemfile: gemfiles/rails_6.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: gemfiles/rails_41.gemfile
164
+ gemfile: rails_41
148
165
  - ruby-version: "2.5"
149
- gemfile: gemfiles/rails_41.gemfile
166
+ gemfile: rails_41
150
167
  - ruby-version: "2.6"
151
- gemfile: gemfiles/rails_41.gemfile
168
+ gemfile: rails_41
152
169
  - ruby-version: "2.7"
153
- gemfile: gemfiles/rails_41.gemfile
170
+ gemfile: rails_41
154
171
  - ruby-version: "2.7"
155
- gemfile: gemfiles/rails_42.gemfile
172
+ gemfile: rails_42
156
173
  beeline:
157
174
  jobs:
158
175
  - lint:
data/.github/CODEOWNERS CHANGED
@@ -2,4 +2,4 @@
2
2
  # This file controls who is tagged for review for any given pull request.
3
3
 
4
4
  # For anything not explicitly taken by someone else:
5
- * @honeycombio/integrations-team @martin308
5
+ * @honeycombio/telemetry-team @martin308
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: Bug report
3
+ about: Let us know if something is not working as expected
4
+ title: ''
5
+ labels: 'type: bug'
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ <!---
11
+ Thank you for taking the time to report bugs!
12
+
13
+ We love code snippets and links to repositories that reproduce the issue, but understand if you don't have the time to add them. We'll do our best with the info you provide, and might ask follow-up questions.
14
+
15
+ Please see our [OSS process document](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md#) to get an idea of how we operate.
16
+ --->
17
+
18
+ **Versions**
19
+
20
+ - Ruby:
21
+ - Beeline:
22
+
23
+ **Steps to reproduce**
24
+
25
+ 1.
26
+
27
+ **Additional context**
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: 'type: enhancement'
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ <!---
11
+ Thank you for contributing an idea to this project!
12
+
13
+ Please see our [OSS process document](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md#) to get an idea of how we operate.
14
+ --->
15
+
16
+ **Is your feature request related to a problem? Please describe.**
17
+
18
+
19
+ **Describe the solution you'd like**
20
+
21
+
22
+ **Describe alternatives you've considered**
23
+
24
+
25
+ **Additional context**
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: Question/Discussion
3
+ about: General question about how things work or a discussion
4
+ title: ''
5
+ labels: 'type: discussion'
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ <!---
11
+ Thank you for taking the time to say hello!
12
+
13
+ Please see our [OSS process document](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md#) to get an idea of how we operate.
14
+ --->
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: Security vulnerability report
3
+ about: Let us know if you discover a security vulnerability
4
+ title: ''
5
+ labels: 'type: security'
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ <!---
11
+ Thank you for taking the time to report security vulnerabilities!
12
+
13
+ Please see our [OSS process document](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md#) to get an idea of how we operate.
14
+ --->
15
+ **Versions**
16
+
17
+ - Ruby:
18
+ - Beeline:
19
+
20
+ **Description**
21
+
22
+ (Please include any relevant CVE advisory links)
@@ -0,0 +1,20 @@
1
+ <!--
2
+ Thank you for contributing to the project! 💜
3
+ Please make sure to:
4
+ - Chat with us first if this is a big change
5
+ - Open a new issue (or comment on an existing one)
6
+ - We want to make sure you don't spend time implementing something we might have to say No to
7
+ - Add unit tests
8
+ - Mention any relevant issues in the PR description (e.g. "Fixes #123")
9
+
10
+ Please see our [OSS process document](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md#) to get an idea of how we operate.
11
+ -->
12
+
13
+ ## Which problem is this PR solving?
14
+
15
+ -
16
+
17
+ ## Short description of the changes
18
+
19
+ -
20
+
@@ -9,5 +9,7 @@ updates:
9
9
  directory: "/gemfiles/" # Location of package manifests
10
10
  schedule:
11
11
  interval: "weekly"
12
+ labels:
13
+ - "type: dependencies"
12
14
  reviewers:
13
- - "honeycombio/integrations-team"
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 }}
@@ -1,16 +1,10 @@
1
1
  name: Apply project labels
2
-
3
- on:
4
- - issues
5
- - label
6
- - pull_request_target
7
- - pull_request
8
-
2
+ on: [issues, pull_request, label]
9
3
  jobs:
10
4
  apply-labels:
11
5
  runs-on: ubuntu-latest
12
6
  name: Apply common project labels
13
7
  steps:
14
- - uses: honeycombio/integrations-labels@v1
8
+ - uses: honeycombio/oss-management-actions/labels@v1
15
9
  with:
16
10
  github-token: ${{ secrets.GITHUB_TOKEN }}
data/.gitignore CHANGED
@@ -5,6 +5,7 @@
5
5
  /doc/
6
6
  /pkg/
7
7
  /spec/reports/
8
+ /test/reports/
8
9
  /tmp/
9
10
  .idea/
10
11
 
data/.rspec CHANGED
@@ -1,3 +1,7 @@
1
+ <% if ENV['CI'] %>
2
+ --format RspecJunitFormatter
3
+ --out test/reports/result.xml
4
+ <% end %>
1
5
  --format documentation
2
6
  --color
3
7
  --require spec_helper
data/.rubocop.yml CHANGED
@@ -27,6 +27,7 @@ Metrics/MethodLength:
27
27
 
28
28
  Metrics/LineLength:
29
29
  Exclude:
30
+ - spec/honeycomb/integrations/active_support_spec.rb
30
31
  - spec/support/event_data_shared_examples.rb
31
32
 
32
33
  Metrics/ParameterLists:
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # beeline-ruby changelog
2
2
 
3
+ ## 2.7.0 2021-09-03
4
+
5
+ ### Improvements
6
+
7
+ - add `error` and `error_detail` fields to spans from `ActiveSupport::Notification` events that contain an exception (#166) | [@leviwilson](https://github.com/leviwilson)
8
+
9
+ ### Maintenance
10
+
11
+ - Add issue and PR templates (#165) | [@vreynolds](https://github.com/vreynolds)
12
+ - Add OSS lifecycle badge (#164) | [@vreynolds](https://github.com/vreynolds)
13
+ - Add community health files (#163) | [@vreynolds](https://github.com/vreynolds)
14
+
15
+ ## 2.6.0 2021-07-23
16
+
17
+ ### Added
18
+
19
+ - Allow setting different notification handling logic for specific events (#152) | [@lirossarvet](https://github.com/lirossarvet)
20
+
21
+ ## 2.5.0 2021-07-16
22
+
23
+ ### Added
24
+
25
+ - Allow backtrace to be sent with errors (#160) | [@lirossarvet](https://github.com/lirossarvet)
26
+
27
+ ### Maintenance
28
+
29
+ - Updates Github Action Workflows (#159) | [@bdarfler](https://github.com/bdarfler)
30
+ - Adds dependabot label (#158) | [@bdarfler](https://github.com/bdarfler)
31
+ - Switches CODEOWNERS to telemetry-team (#157) | [@bdarfler](https://github.com/bdarfler)
32
+
33
+ ## 2.4.2 2021-06-25
34
+
35
+ ### Fixes
36
+
37
+ - Update Rails middleware to get status code even on raised error. (#153) [@lirossarvet](https://github.com/lirossarvet)
38
+ - Make Rails spec consistent with Honeycomb Railtie Initialization. (#154) [@robbkidd](https://github.com/robbkidd)
39
+ - CI Improvements (#155) [@robbkidd](https://github.com/robbkidd)
40
+ - Improve performance of Redis command serialization. (#146) [@ajvondrak](https://github.com/ajvondrak)
41
+
3
42
  ## 2.4.1 2021-06-01
4
43
 
5
44
  ### Fixes
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,74 +1,5 @@
1
- # Contributor Covenant Code of Conduct
1
+ # Code of Conduct
2
2
 
3
- ## Our Pledge
3
+ This project has adopted the Honeycomb User Community Code of Conduct to clarify expected behavior in our community.
4
4
 
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at me@martinholman.co.nz. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
5
+ https://www.honeycomb.io/honeycomb-user-community-code-of-conduct/
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,3 @@
1
+ # Contributing Guide
2
+
3
+ Please see our [general guide for OSS lifecycle and practices.](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- honeycomb-beeline (2.4.1)
4
+ honeycomb-beeline (2.7.0)
5
5
  libhoney (~> 1.14, >= 1.14.2)
6
6
 
7
7
  GEM
@@ -40,7 +40,7 @@ GEM
40
40
  http-cookie (~> 1.0)
41
41
  http-form_data (~> 2.2)
42
42
  http-parser (~> 1.2.0)
43
- http-cookie (1.0.3)
43
+ http-cookie (1.0.4)
44
44
  domain_name (~> 0.5)
45
45
  http-form_data (2.3.0)
46
46
  http-parser (1.2.3)
@@ -81,6 +81,8 @@ GEM
81
81
  diff-lcs (>= 1.2.0, < 2.0)
82
82
  rspec-support (~> 3.9.0)
83
83
  rspec-support (3.9.3)
84
+ rspec_junit_formatter (0.4.1)
85
+ rspec-core (>= 2, < 4, != 2.12.0)
84
86
  rubocop (0.68.1)
85
87
  jaro_winkler (~> 1.5.1)
86
88
  parallel (~> 1.10)
@@ -126,6 +128,7 @@ DEPENDENCIES
126
128
  pry-byebug (~> 3.6.0)
127
129
  rake
128
130
  rspec (~> 3.0)
131
+ rspec_junit_formatter
129
132
  rubocop (< 0.69)
130
133
  rubocop-performance (< 1.3.0)
131
134
  simplecov
@@ -133,4 +136,4 @@ DEPENDENCIES
133
136
  webmock
134
137
 
135
138
  BUNDLED WITH
136
- 2.1.4
139
+ 2.2.21
data/OSSMETADATA ADDED
@@ -0,0 +1 @@
1
+ osslifecycle=maintenance
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Honeycomb Beeline for Ruby
2
2
 
3
+ [![OSS Lifecycle](https://img.shields.io/osslifecycle/honeycombio/beeline-ruby)](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md)
3
4
  [![Build Status](https://circleci.com/gh/honeycombio/beeline-ruby.svg?style=svg)](https://circleci.com/gh/honeycombio/beeline-ruby)
4
5
  [![Gem Version](https://badge.fury.io/rb/honeycomb-beeline.svg)](https://badge.fury.io/rb/honeycomb-beeline)
5
6
  [![codecov](https://codecov.io/gh/honeycombio/beeline-ruby/branch/main/graph/badge.svg)](https://codecov.io/gh/honeycombio/beeline-ruby)
data/RELEASING.md ADDED
@@ -0,0 +1,11 @@
1
+ # Releasing
2
+
3
+ - Update the version number in `lib/honeycomb/beeline/version`.
4
+ - Run `bundle lock`.
5
+ - Confirm the version number update appears in `Gemfile.lock`
6
+ - Update `CHANGELOG.md` with the changes since the last release.
7
+ - Commit changes, push, and open a release preparation pull request for review.
8
+ - Once the pull request is merged, fetch the updated `main` branch.
9
+ - Apply a tag for the new version on the merged commit: vX.Y.Z, for example v1.1.2.
10
+ - Push the new version tag up to the project repository to kick off build and artifact publishing to GitHub and the Gems registry.
11
+ - Publish the draft release in GitHub.
data/SECURITY.md ADDED
@@ -0,0 +1,3 @@
1
+ # Reporting Security Issues
2
+
3
+ If you discover a security vulnerability, please open an issue with label `type: security`.
data/SUPPORT.md ADDED
@@ -0,0 +1,3 @@
1
+ # How to Get Help
2
+
3
+ This project uses GitHub issues to track bugs, feature requests, and questions about using the project. Please search for existing issues before filing a new one.
@@ -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"
@@ -3,7 +3,7 @@
3
3
  module Honeycomb
4
4
  module Beeline
5
5
  NAME = "honeycomb-beeline".freeze
6
- VERSION = "2.4.1".freeze
6
+ VERSION = "2.7.0".freeze
7
7
  USER_AGENT_SUFFIX = "#{NAME}/#{VERSION}".freeze
8
8
  end
9
9
  end
@@ -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
- if context.current_trace.nil?
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.add_field("error", e.class.name)
73
- current_span.add_field("error_detail", e.message)
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
- attr_accessor :notification_events
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,23 +22,44 @@ module Honeycomb
21
22
  end
22
23
  end
23
24
 
24
- def on_notification_event(&hook)
25
- if block_given?
26
- @on_notification_event = hook
25
+ def on_notification_event(event_name = nil, &hook)
26
+ if event_name
27
+ active_support_handlers[event_name] = hook
27
28
  else
28
- @on_notification_event
29
+ @default_handler = hook
29
30
  end
30
31
  end
31
32
 
32
33
  def handle_notification_event(name, span, payload)
33
- if on_notification_event
34
- on_notification_event.call(name, span, payload)
35
- else
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)
39
52
  span.add_field("#{name}.#{key}", value)
40
53
  end
54
+
55
+ # If the notification event has recorded an exception, add the
56
+ # Beeline's usual error fields to the span.
57
+ # * Uses the 2-element array on :exception in the event payload
58
+ # to support Rails 4. If Rails 4 support is dropped, consider
59
+ # the :exception_object added in Rails 5.
60
+ error, error_detail = payload[:exception]
61
+ span.add_field("error", error) if error
62
+ span.add_field("error_detail", error_detail) if error_detail
41
63
  end
42
64
  end
43
65
  end
@@ -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
- status, headers, body = app.call(env)
52
-
53
- add_package_information(env, &add_field)
54
-
55
- extract_user_information(env, &add_field)
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
@@ -187,16 +187,6 @@ module Honeycomb
187
187
  args.map! { "[sanitized]" }
188
188
  end
189
189
 
190
- def prettify(arg)
191
- quotes = false
192
- pretty = "".dup
193
- arg.to_s.each_char do |c|
194
- quotes ||= needs_quotes?(c)
195
- pretty << escape(c)
196
- end
197
- quotes ? "\"#{pretty}\"" : pretty
198
- end
199
-
200
190
  # This aims to replicate the algorithms used by redis-cli.
201
191
  #
202
192
  # @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L940-L1067
@@ -204,54 +194,15 @@ module Honeycomb
204
194
  #
205
195
  # @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L878-L907
206
196
  # The redis-cli printing algorithm
207
- def escape(char)
208
- return escape_with_backslash(char) if escape_with_backslash?(char)
209
- return escape_with_hex_codes(char) if escape_with_hex_codes?(char)
210
-
211
- char
212
- end
213
-
214
- # A lookup table for backslash-escaped characters.
215
- #
216
- # This is used by {#escape_with_backslash?} and {#escape_with_backslash}
217
- # to replicate the hard-coded `case` statements in redis-cli. As of this
218
- # writing, Redis recognizes a handful of standard C escape sequences,
219
- # like "\n" for newlines.
220
- #
221
- # Because {#prettify} will output double quoted strings if any escaping
222
- # is needed, this table must additionally consider the double-quote to be
223
- # a backslash-escaped character. For example, instead of generating
224
- #
225
- # '"hello"'
226
- #
227
- # we'll generate
228
- #
229
- # "\"hello\""
230
- #
231
- # even though redis-cli would technically recognize the single-quoted
232
- # version.
233
- #
234
- # @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L888-L896
235
- # The redis-cli algorithm for outputting standard escape sequences
236
- BACKSLASHES = {
237
- "\\" => "\\\\",
238
- '"' => '\\"',
239
- "\n" => "\\n",
240
- "\r" => "\\r",
241
- "\t" => "\\t",
242
- "\a" => "\\a",
243
- "\b" => "\\b",
244
- }.freeze
245
-
246
- def escape_with_backslash?(char)
247
- BACKSLASHES.key?(char)
248
- end
249
-
250
- def escape_with_backslash(char)
251
- 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
252
203
  end
253
204
 
254
- # Do we need to hex-encode this character?
205
+ # A regular expression matching characters that need to be hex-encoded.
255
206
  #
256
207
  # This replicates the C isprint() function that redis-cli uses to decide
257
208
  # whether to escape a character in hexadecimal notation, "\xhh". Any
@@ -287,18 +238,95 @@ module Honeycomb
287
238
  # escape it.
288
239
  #
289
240
  # What's more, Ruby's Regexp#=~ method will blow up if the string does
290
- # not have a valid encoding (e.g., in UTF-8). In this case, though,
291
- # {#escape_with_hex_codes} can still convert the bytes that make up the
292
- # invalid character into a hex code. So we preemptively check for
293
- # 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}.
294
244
  #
295
245
  # @see https://ruby-doc.org/core-2.6.5/Regexp.html
296
246
  # @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L878-L880
297
247
  # @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L898-L901
298
248
  # @see https://www.justinweiss.com/articles/3-steps-to-fix-encoding-problems-in-ruby/
299
- def escape_with_hex_codes?(char)
300
- !char.valid_encoding? || char =~ /[^[:print:]&&[:ascii:]]/
301
- end
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
302
330
 
303
331
  # Hex-encodes a (presumably non-printable or non-ASCII) character.
304
332
  #
@@ -326,38 +354,9 @@ module Honeycomb
326
354
  # @see https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html
327
355
  # @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L878-L880
328
356
  # @see https://github.com/antirez/redis/blob/0f026af185e918a9773148f6ceaa1b084662be88/src/sds.c#L898-L901
329
- def escape_with_hex_codes(char)
357
+ def hex(char)
330
358
  char.bytes.map { |b| Kernel.format("\\x%02x", b) }.join
331
359
  end
332
-
333
- def escape?(char)
334
- escape_with_backslash?(char) || escape_with_hex_codes?(char)
335
- end
336
-
337
- # Should this character cause {#prettify} to wrap its output in quotes?
338
- #
339
- # The overall string returned by {#prettify} should only be quoted if at
340
- # least one of the following holds:
341
- #
342
- # 1. The string contains a character that needs to be escaped. This
343
- # includes standard backslash escape sequences (like "\n" and "\t") as
344
- # well as hex-encoded bytes using the "\x" escape sequence. Since
345
- # {#prettify} uses double quotes on its output string, we must also
346
- # force quotes if the string itself contains a literal double quote.
347
- # This double quote behavior is handled tacitly by {BACKSLASHES}.
348
- #
349
- # 2. The string contains a single quote. Since redis-cli recognizes
350
- # single-quoted strings, we want to wrap the {#prettify} output in
351
- # double quotes so that the literal single quote character isn't
352
- # mistaken as the delimiter of a new string.
353
- #
354
- # 3. The string contains any whitespace characters. If the {#prettify}
355
- # output weren't wrapped in quotes, whitespace would act as a
356
- # separator between arguments to the Redis command. To group things
357
- # together, we need to quote the string.
358
- def needs_quotes?(char)
359
- escape?(char) || char == "'" || char =~ /\s/
360
- end
361
360
  end
362
361
  end
363
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.1
4
+ version: 2.7.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-06-01 00:00:00.000000000 Z
11
+ date: 2021-09-07 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,22 +252,34 @@ files:
238
252
  - ".circleci/setup-rubygems.sh"
239
253
  - ".editorconfig"
240
254
  - ".github/CODEOWNERS"
255
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
256
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
257
+ - ".github/ISSUE_TEMPLATE/question-discussion.md"
258
+ - ".github/ISSUE_TEMPLATE/security-vulnerability-report.md"
259
+ - ".github/PULL_REQUEST_TEMPLATE.md"
241
260
  - ".github/dependabot.yml"
261
+ - ".github/workflows/add-to-project.yml"
242
262
  - ".github/workflows/apply-labels.yml"
243
263
  - ".gitignore"
244
264
  - ".overcommit.yml"
245
265
  - ".rspec"
246
266
  - ".rubocop.yml"
247
267
  - ".ruby-version"
268
+ - ".tool-versions"
248
269
  - Appraisals
249
270
  - CHANGELOG.md
250
271
  - CODE_OF_CONDUCT.md
272
+ - CONTRIBUTING.md
251
273
  - CONTRIBUTORS.md
252
274
  - Gemfile
253
275
  - Gemfile.lock
254
276
  - LICENSE
277
+ - OSSMETADATA
255
278
  - README.md
279
+ - RELEASING.md
256
280
  - Rakefile
281
+ - SECURITY.md
282
+ - SUPPORT.md
257
283
  - UPGRADING.md
258
284
  - bin/console
259
285
  - bin/setup