libhoney 1.19.0 → 2.1.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: 40d54151fc103bf8020f14ff8b7a9e6e0298366869e795ce3ddf0438af066e16
4
- data.tar.gz: c2b834d39609a73bce6e5e6e19caf4d2499903498895d32fe22b55041db7e59b
3
+ metadata.gz: 87accb91b956f38c24050ebc8931d49041ab02551c394a7447434730eb827f18
4
+ data.tar.gz: 899a27302a4e04e2ac50af6f792a8515b252a838bb6b09d9471bf6aab9058cbc
5
5
  SHA512:
6
- metadata.gz: 24d9d44cb0f1f5ad7549b75067dd6cbc2eb2264b8cad1c1c8cf523c19d955e41b91feb86d6cde74104885fc61ee4c4f5309b3ed46edfc5751483ba282d5e841e
7
- data.tar.gz: 1b1690d32daf8f44a19761d2ccc26a5a099d1daec623ecd481776f34ea439506278c267ff8b319c0ccb380ec497ca1de4b6e9c2a7eee677a1584d9d1cfe1ec87
6
+ metadata.gz: 42b5a14b536bdda18f2900e2767c4702dd16e5a441300830c9a6cd7ae15d3e4c7d6b0edb3346bb278f239731b16ca8bc807851d57d3d3ad6da185782a48bf64c
7
+ data.tar.gz: 1e764f94ded5a848f6a90197f340d31efbc13b2fa6eae9f7be2444a19b8a8e65165356d68cd76dd51f5ce8910e742db9fd8a49546170b4dafa4d99471445979d
data/.circleci/config.yml CHANGED
@@ -19,10 +19,10 @@ filters_publish: &filters_publish
19
19
  matrix_rubyversions: &matrix_rubyversions
20
20
  matrix:
21
21
  parameters:
22
- rubyversion: ["2.2", "2.3", "2.4", "2.5", "2.6", "2.7"]
22
+ rubyversion: ["2.4", "2.5", "2.6", "2.7", "3.0"]
23
23
 
24
24
  # Default version of ruby to use for lint and publishing
25
- default_rubyversion: &default_rubyversion "2.7"
25
+ default_rubyversion: &default_rubyversion "3.0"
26
26
 
27
27
  executors:
28
28
  ruby:
@@ -31,7 +31,7 @@ executors:
31
31
  type: string
32
32
  default: *default_rubyversion
33
33
  docker:
34
- - image: circleci/ruby:<< parameters.rubyversion >>
34
+ - image: cimg/ruby:<< parameters.rubyversion >>
35
35
  github:
36
36
  docker:
37
37
  - image: cibuilds/github:0.13.0
@@ -86,7 +86,8 @@ jobs:
86
86
  - run:
87
87
  name: install dependencies
88
88
  command: |
89
- bundle install --jobs=4 --retry=3 --path vendor/bundle
89
+ bundle config set --local path 'vendor/bundle'
90
+ bundle install --jobs=4 --retry=3
90
91
  - save_cache:
91
92
  paths:
92
93
  - ./vendor/bundle
@@ -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
+ - Libhoney:
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
+ - Libhoney:
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
+
@@ -8,7 +8,7 @@ updates:
8
8
  - package-ecosystem: "bundler" # See documentation for possible values
9
9
  directory: "/" # Location of package manifests
10
10
  schedule:
11
- interval: "weekly"
11
+ interval: "monthly"
12
12
  labels:
13
13
  - "type: dependencies"
14
14
  reviewers:
@@ -1,5 +1,5 @@
1
1
  name: Apply project labels
2
- on: [issues, pull_request, label]
2
+ on: [issues, pull_request_target, label]
3
3
  jobs:
4
4
  apply-labels:
5
5
  runs-on: ubuntu-latest
@@ -0,0 +1,12 @@
1
+ name: Re-triage issues with new comments
2
+ on:
3
+ issue_comment:
4
+ types: [created]
5
+ jobs:
6
+ re-triage:
7
+ runs-on: ubuntu-latest
8
+ name: Re-triage issues with new comments
9
+ steps:
10
+ - uses: honeycombio/oss-management-actions/re-triage@v1
11
+ with:
12
+ ghprojects-token: ${{ secrets.GHPROJECTS_TOKEN }}
@@ -0,0 +1,26 @@
1
+ name: 'Close stale issues and PRs'
2
+ on:
3
+ schedule:
4
+ - cron: '30 1 * * *'
5
+
6
+ jobs:
7
+ stale:
8
+ name: 'Close stale issues and PRs'
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ issues: write
12
+ pull-requests: write
13
+
14
+ steps:
15
+ - uses: actions/stale@v4
16
+ with:
17
+ start-date: '2021-09-01T00:00:00Z'
18
+ stale-issue-message: 'Marking this issue as stale because it has been open 14 days with no activity. Please add a comment if this is still an ongoing issue; otherwise this issue will be automatically closed in 7 days.'
19
+ stale-pr-message: 'Marking this PR as stale because it has been open 30 days with no activity. Please add a comment if this PR is still relevant; otherwise this PR will be automatically closed in 7 days.'
20
+ close-issue-message: 'Closing this issue due to inactivity. Please see our [Honeycomb OSS Lifecyle and Practices](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md).'
21
+ close-pr-message: 'Closing this PR due to inactivity. Please see our [Honeycomb OSS Lifecyle and Practices](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md).'
22
+ days-before-issue-stale: 14
23
+ days-before-pr-stale: 30
24
+ days-before-issue-close: 7
25
+ days-before-pr-close: 7
26
+ any-of-labels: 'status: info needed,status: revision needed'
data/.rubocop.yml CHANGED
@@ -1,11 +1,33 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.2
4
+ TargetRubyVersion: 2.4
5
+ NewCops: enable
5
6
 
6
7
  Style/Documentation:
7
8
  Enabled: false
8
9
 
10
+ Layout/BeginEndAlignment:
11
+ EnforcedStyleAlignWith: begin
12
+
13
+ Layout/EmptyLineBetweenDefs:
14
+ AllowAdjacentOneLineDefs: true
15
+
16
+ Lint/RaiseException:
17
+ Enabled: true
18
+
19
+ Lint/StructNewOverride:
20
+ Enabled: true
21
+
22
+ Style/HashEachMethods:
23
+ Enabled: true
24
+
25
+ Style/HashTransformKeys:
26
+ Enabled: true
27
+
28
+ Style/HashTransformValues:
29
+ Enabled: true
30
+
9
31
  Lint/RescueException:
10
32
  Exclude:
11
33
  - 'lib/libhoney/transmission.rb'
@@ -26,7 +48,7 @@ Metrics/MethodLength:
26
48
  - lib/libhoney/transmission.rb
27
49
  - test/*
28
50
 
29
- Metrics/LineLength:
51
+ Layout/LineLength:
30
52
  Max: 115
31
53
  Exclude:
32
54
  - lib/libhoney/client.rb
data/.rubocop_todo.yml CHANGED
@@ -1,36 +1,42 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-09-24 20:37:04 -0700 using RuboCop version 0.59.2.
3
+ # on 2021-09-10 20:37:20 UTC using RuboCop version 1.12.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 3
10
- Lint/HandleExceptions:
9
+ # Offense count: 2
10
+ # Configuration parameters: AllowComments, AllowNil.
11
+ Lint/SuppressedException:
11
12
  Exclude:
12
- - 'lib/libhoney/client.rb'
13
13
  - 'lib/libhoney/transmission.rb'
14
14
 
15
- # Offense count: 7
15
+ # Offense count: 12
16
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
16
17
  Metrics/AbcSize:
17
- Max: 40
18
-
19
- # Offense count: 1
20
- # Configuration parameters: CountComments, ExcludedMethods.
21
- # ExcludedMethods: refine
22
- Metrics/BlockLength:
23
- Max: 30
18
+ Max: 38
24
19
 
25
- # Offense count: 2
20
+ # Offense count: 6
21
+ # Configuration parameters: IgnoredMethods.
26
22
  Metrics/CyclomaticComplexity:
27
23
  Max: 12
28
24
 
29
- # Offense count: 2
30
- # Configuration parameters: CountKeywordArgs.
25
+ # Offense count: 1
26
+ # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
31
27
  Metrics/ParameterLists:
32
- Max: 12
28
+ Max: 10
33
29
 
34
- # Offense count: 1
30
+ # Offense count: 4
31
+ # Configuration parameters: IgnoredMethods.
35
32
  Metrics/PerceivedComplexity:
36
- Max: 10
33
+ Max: 11
34
+
35
+ # Offense count: 31
36
+ # Cop supports --auto-correct.
37
+ # Configuration parameters: EnforcedStyle.
38
+ # SupportedStyles: always, always_true, never
39
+ # Disabled after setting target version to 2.3
40
+ # Consider later.
41
+ Style/FrozenStringLiteralComment:
42
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,6 +1,48 @@
1
- # libhoney-rb changelog
1
+ ## [2.1.0] - 2022-02-02
2
2
 
3
- ## changes pending release
3
+ ### Improvements
4
+
5
+ - Retry an event batch send once if the connection appears to have been closed by the server due to idleness (#120) | [MikeGoldsmith](https://github.com/MikeGoldsmith)
6
+
7
+ ### Maintenance
8
+
9
+ - gh: add re-triage workflow (#117) | [vreynolds](https://github.com/vreynolds)
10
+ - Update dependabot to monthly (#116) | [vreynolds](https://github.com/vreynolds)
11
+ - empower apply-labels action to apply labels (#115) | [robbkidd](https://github.com/robbkidd)
12
+
13
+ ## [2.0.0] - 2021-10-07
14
+
15
+ ### 💥 Breaking Changes
16
+
17
+ - support dropped for Ruby 2.2 (#104) | [robbkidd](https://github.com/robbkidd)
18
+ - support dropped for Ruby 2.3 (#106) | [robbkidd](https://github.com/robbkidd)
19
+ - remove deprecated support for accepting an Array for client proxy_config (#112) | [robbkidd](https://github.com/robbkidd)
20
+
21
+ ### 🛠 Maintenance
22
+
23
+ - Change maintenance badge to maintained (#109) | [JamieDanielson](https://github.com/JamieDanielson)
24
+ - Adds Stalebot (#110) | [JamieDanielson](https://github.com/JamieDanielson)
25
+
26
+ ## [1.21.0] - 2021-09-23
27
+
28
+ ### Added
29
+
30
+ - Include Ruby runtime info in user agent (#105) | [robbkidd](https://github.com/robbkidd)
31
+
32
+ ### Maintenance
33
+
34
+ - Update http requirement from >= 2.0, < 5.0 to >= 2.0, < 6.0 (#100)
35
+ - Update spy requirement to accept any 1.x release (#102)
36
+ - Update rake requirement from ~> 12.3 to ~> 13.0 (#101)
37
+ - Add issue and PR templates (#99)
38
+ - Add OSS lifecycle badge (#98)
39
+ - Add community health files (#97)
40
+
41
+ ## 1.20.0
42
+
43
+ ### Fixes
44
+
45
+ - Handle Timeout::Error in TransmissionClient (#95) | [Adam Pohorecki](https://github.com/psyho)
4
46
 
5
47
  ## 1.19.0
6
48
 
@@ -44,7 +86,7 @@
44
86
 
45
87
  - Don't moneypatch Class (#70)
46
88
 
47
- ### Maintenance:
89
+ ### Maintenance:
48
90
 
49
91
  - Add lockfile to gitignore (#71)
50
92
 
@@ -0,0 +1,5 @@
1
+ # Code of Conduct
2
+
3
+ This project has adopted the Honeycomb User Community Code of Conduct to clarify expected behavior in our community.
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/CONTRIBUTORS CHANGED
@@ -10,3 +10,4 @@ Eben Freeman <eben@honeycomb.io>
10
10
  Ryan King <ryan@theryanking.com>
11
11
  Paul Sadauskas <psadauskas@gmail.com>
12
12
  Shane Becker <veganstraightedge@gmail.com>
13
+ Adam Pohorecki <adam@pohorecki.pl>
data/OSSMETADATA ADDED
@@ -0,0 +1 @@
1
+ osslifecycle=maintained
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
- # libhoney [![CircleCI Build Status](https://circleci.com/gh/honeycombio/libhoney-rb.svg?style=svg)](https://circleci.com/gh/honeycombio/libhoney-rb) [![Gem Version](https://badge.fury.io/rb/libhoney.svg)](https://badge.fury.io/rb/libhoney)
1
+ # libhoney
2
+
3
+ [![OSS Lifecycle](https://img.shields.io/osslifecycle/honeycombio/libhoney-rb?color=success)](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md)
4
+ [![CircleCI Build Status](https://circleci.com/gh/honeycombio/libhoney-rb.svg?style=svg)](https://circleci.com/gh/honeycombio/libhoney-rb)
5
+ [![Gem Version](https://badge.fury.io/rb/libhoney.svg)](https://badge.fury.io/rb/libhoney)
2
6
 
3
7
  Ruby gem for sending events to [Honeycomb](https://www.honeycomb.io), a service for debugging your software in production.
4
8
 
5
- Requires Ruby 2.2 or greater.
9
+ Requires Ruby 2.3 or greater.
6
10
 
7
11
  - [Usage and Examples](https://docs.honeycomb.io/sdk/ruby/)
8
12
  - [API Reference](https://www.rubydoc.info/gems/libhoney)
@@ -16,15 +20,3 @@ open issues or a pull request with your change. Remember to add your name to the
16
20
  CONTRIBUTORS file!
17
21
 
18
22
  All contributions will be released under the Apache License 2.0.
19
-
20
- ### Releasing a new version
21
-
22
- CircleCI will automatically upload tagged releases to Rubygems. To release a new
23
- version, update the version using `bump`.
24
-
25
- ```
26
- bump patch # Or bump minor, etc.
27
- ```
28
-
29
- Then, after the version change has been merged into `main`, follow our usual instructions
30
- for tagging and updating the github release.
data/RELEASING.md ADDED
@@ -0,0 +1,12 @@
1
+ # Releasing
2
+
3
+ - Update the version number in `lib/libhoney/version.rb`.
4
+ - For convenience, you can run `bump --no-commit --changelog (major|minor|patch)` to perform
5
+ the version bump and to add the new version's header to the CHANGELOG. `--no-commit` because
6
+ there are more changes to make that we do manually.
7
+ - Update `CHANGELOG.md` with the changes since the last release.
8
+ - Commit changes, push, and open a release preparation pull request for review.
9
+ - Once the pull request is merged, fetch the updated `main` branch.
10
+ - Apply a tag for the new version on the merged commit: vX.Y.Z, for example v1.1.2.
11
+ - Push the new version tag up to the project repository to kick off build and artifact publishing to GitHub and the Gems registry.
12
+ - 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.
data/example/factorial.rb CHANGED
@@ -8,7 +8,7 @@ writekey = '7aefa39399a474bd9f414a8e3f8d9691'
8
8
  dataset = 'factorial'
9
9
 
10
10
  def factorial(number)
11
- return -1 * factorial(abs(number)) if number < 0
11
+ return -1 * factorial(abs(number)) if number.negative?
12
12
  return 1 if number.zero?
13
13
 
14
14
  number * factorial(number - 1)
@@ -2,8 +2,7 @@ require 'libhoney/event'
2
2
 
3
3
  module Libhoney
4
4
  class Builder
5
- attr_accessor :writekey, :dataset, :sample_rate, :api_host
6
- attr_accessor :fields, :dyn_fields
5
+ attr_accessor :writekey, :dataset, :sample_rate, :api_host, :fields, :dyn_fields
7
6
 
8
7
  # @api private
9
8
  # @see Client#builder
@@ -55,13 +55,10 @@ module Libhoney
55
55
  # @param block_on_responses [Boolean] if true, block if there is no thread reading from the response queue
56
56
  # @param pending_work_capacity [Fixnum] defaults to 1000. If the queue of
57
57
  # pending events exceeds 1000, this client will start dropping events.
58
- # @param proxy_config [String, Array, nil] proxy connection information
58
+ # @param proxy_config [String, nil] proxy connection information
59
59
  # nil: (default, recommended) connection proxying will be determined from any http_proxy, https_proxy, and no_proxy environment
60
60
  # variables set for the process.
61
61
  # String: the value must be the URI for connecting to a forwarding web proxy. Must be parsable by stdlib URI.
62
- # Array: (deprecated, removal in v2.0) the value must have one and at most four elements: e.g. ['host', port, 'username', 'password'].
63
- # The assumption is that the TCP connection will be tunneled via HTTP, so the assumed scheme is 'http://'
64
- # 'host' is required. 'port' is optional (default:80), unless a 'username' is included. 'password' is optional.
65
62
  # rubocop:disable Metrics/ParameterLists
66
63
  def initialize(writekey: nil,
67
64
  dataset: nil,
@@ -78,12 +75,8 @@ module Libhoney
78
75
  proxy_config: nil)
79
76
  # rubocop:enable Metrics/ParameterLists
80
77
  # check for insanity
81
- raise Exception, 'libhoney: max_concurrent_batches must be greater than 0' if max_concurrent_batches < 1
82
- raise Exception, 'libhoney: sample rate must be greater than 0' if sample_rate < 1
83
-
84
- unless Gem::Dependency.new('ruby', '>= 2.2').match?('ruby', RUBY_VERSION)
85
- raise Exception, 'libhoney: Ruby versions < 2.2 are not supported'
86
- end
78
+ raise 'libhoney: max_concurrent_batches must be greater than 0' if max_concurrent_batches < 1
79
+ raise 'libhoney: sample rate must be greater than 0' if sample_rate < 1
87
80
 
88
81
  @builder = Builder.new(self, nil)
89
82
 
@@ -114,7 +107,7 @@ module Libhoney
114
107
 
115
108
  # Nuke the queue and wait for inflight requests to complete before returning.
116
109
  # If you set drain=false, all queued requests will be dropped on the floor.
117
- def close(drain = true)
110
+ def close(drain = true) # rubocop:disable Style/OptionalBooleanParameter
118
111
  return @transmission.close(drain) if @transmission
119
112
 
120
113
  0
@@ -244,18 +237,20 @@ module Libhoney
244
237
  end
245
238
 
246
239
  case transmission
240
+ # rubocop:disable Style/GuardClause, Style/RedundantReturn
247
241
  when NilClass # the default value for new clients
248
242
  return TransmissionClient.new(**transmission_client_params)
249
243
  when Class
250
244
  # if a class has been provided, attempt to instantiate it with parameters given to the client
251
245
  t = transmission.new(**transmission_client_params)
252
- if quacks_like_a_transmission?(t) # rubocop:disable Style/GuardClause
246
+ if quacks_like_a_transmission?(t)
253
247
  return t
254
248
  else
255
249
  warn "#{t.class.name}: does not appear to behave like a transmission, disabling sending events"
256
250
  return NullTransmissionClient.new
257
251
  end
258
252
  end
253
+ # rubocop:enable Style/GuardClause, Style/RedundantReturn
259
254
  end
260
255
 
261
256
  def quacks_like_a_transmission?(transmission)
@@ -269,22 +264,13 @@ module Libhoney
269
264
  when String
270
265
  URI.parse(config)
271
266
  when Array
272
- warn <<-WARNING
273
- DEPRECATION WARNING: #{self.class.name} the proxy_config parameter will require a String value, not an Array in libhoney 2.0.
274
- To resolve:
275
- + recommended: set http/https_proxy environment variables, which take precedence over any option set here, then remove proxy_config parameter from client initialization
276
- + set proxy_config to a String containing the forwarding proxy URI (only used if http/https_proxy are not set)
277
- WARNING
278
- host, port, user, password = config
279
-
280
- parsed_config = URI::HTTP.build(host: host, port: port).tap do |uri|
281
- uri.userinfo = "#{user}:#{password}" if user
282
- end
283
- redacted_config = parsed_config.dup.tap do |uri|
284
- uri.password = 'REDACTED' unless uri.password.nil? || uri.password.empty?
285
- end
286
- warn "The array config given has been assumed to mean: #{redacted_config}"
287
- parsed_config
267
+ error_message = <<~MESSAGE
268
+ #{self.class.name}: the optional proxy_config parameter requires a String value; Array is no longer supported.
269
+ To resolve:
270
+ + recommended: set http/https_proxy environment variables, which take precedence over any option set here, then remove proxy_config parameter from client initialization
271
+ + set proxy_config to a String containing the forwarding proxy URI (only used if http/https_proxy environment variables are not set)
272
+ MESSAGE
273
+ raise error_message
288
274
  end
289
275
  rescue URI::Error => e
290
276
  warn "#{self.class.name}: unable to parse proxy_config. Detail: #{e.class}: #{e.message}"
@@ -101,9 +101,7 @@ module Libhoney
101
101
  end
102
102
 
103
103
  def build_user_agent(user_agent_addition)
104
- ua = "libhoney-rb/#{VERSION} (exp-transmission)"
105
- ua << " #{user_agent_addition}" if user_agent_addition
106
- ua
104
+ super("(exp-transmission) #{user_agent_addition}".strip)
107
105
  end
108
106
  end
109
107
  end
@@ -10,7 +10,7 @@ module Libhoney
10
10
  # to verify what events your instrumented code is sending. Use in
11
11
  # production is not recommended.
12
12
  class LogClient < Client
13
- def initialize(*args, output: ::STDERR, verbose: false, **kwargs)
13
+ def initialize(*args, output: $stderr, verbose: false, **kwargs)
14
14
  super(*args,
15
15
  transmission: LogTransmissionClient.new(output: output, verbose: verbose),
16
16
  **kwargs)
@@ -115,7 +115,7 @@ module Libhoney
115
115
  # @param timeout [:never, Numeric] the amount of time in (seconds?) to wait, or :never to wait forever
116
116
  # @param timeout_policy [#call] a callable, what to do when a timeout occurs? Return a default? Raise an
117
117
  # exception? You decide.
118
- def wait_for_condition(condition, condition_predicate, timeout = :never, timeout_policy = -> { nil })
118
+ def wait_for_condition(condition, condition_predicate, timeout = :never, timeout_policy = -> {})
119
119
  deadline = timeout == :never ? :never : trustworthy_current_time + timeout
120
120
  @lock.synchronize do
121
121
  loop do
@@ -74,11 +74,7 @@ module Libhoney
74
74
  'X-Honeycomb-Team' => writekey
75
75
  }
76
76
 
77
- response = http.post(
78
- path: "/1/batch/#{Addressable::URI.escape(dataset)}",
79
- body: body,
80
- headers: headers
81
- )
77
+ response = send_with_retry(http, dataset, body, headers)
82
78
  process_response(response, before, batch)
83
79
  rescue Exception => e
84
80
  # catch a broader swath of exceptions than is usually good practice,
@@ -124,10 +120,7 @@ module Libhoney
124
120
  end
125
121
 
126
122
  @batch_queue.enq(nil)
127
- if @batch_thread.nil?
128
- else
129
- @batch_thread.join(1.0) # limit the amount of time we'll wait for the thread to end
130
- end
123
+ @batch_thread&.join(1.0) # limit the amount of time we'll wait for the thread to end
131
124
 
132
125
  # send @threads.length number of nils so each thread will fall out of send_loop
133
126
  @threads.length.times { @send_queue << nil }
@@ -172,6 +165,9 @@ module Libhoney
172
165
  # 4. flushes the current batch
173
166
  # 5. ends the batch_loop
174
167
  break
168
+ rescue Timeout::Error
169
+ # Timeout::Error happens when there is nothing to pop from the batch_queue.
170
+ # We rescue it here to avoid spamming the logs with "execution expired" errors.
175
171
  rescue Exception => e
176
172
  warn "#{self.class.name}: 💥 " + e.message if %w[debug trace].include?(ENV['LOG_LEVEL'])
177
173
  warn e.backtrace.join("\n").to_s if ['trace'].include?(ENV['LOG_LEVEL'])
@@ -294,14 +290,15 @@ module Libhoney
294
290
  end
295
291
 
296
292
  def build_user_agent(user_agent_addition)
297
- ua = "libhoney-rb/#{VERSION}"
298
- ua << " #{user_agent_addition}" if user_agent_addition
299
- ua
293
+ "libhoney-rb/#{VERSION}"
294
+ .concat(" #{user_agent_addition}")
295
+ .strip # remove trailing spaces if addition was empty
296
+ .concat(" Ruby/#{RUBY_VERSION} (#{RUBY_PLATFORM})")
300
297
  end
301
298
 
302
299
  def ensure_threads_running
303
300
  @lock.synchronize do
304
- @batch_thread = Thread.new { batch_loop } unless @batch_thread && @batch_thread.alive?
301
+ @batch_thread = Thread.new { batch_loop } unless @batch_thread&.alive?
305
302
  @threads.select!(&:alive?)
306
303
  @threads << Thread.new { send_loop } while @threads.length < @max_concurrent_batches
307
304
  end
@@ -336,5 +333,33 @@ module Libhoney
336
333
  h[api_host] = client
337
334
  end
338
335
  end
336
+
337
+ def send_with_retry(client, dataset, body, headers)
338
+ attempts = 0
339
+ begin
340
+ attempts += 1
341
+ client.post(
342
+ path: "/1/batch/#{Addressable::URI.escape(dataset)}",
343
+ body: body,
344
+ headers: headers
345
+ )
346
+ rescue Excon::Error::Socket => e
347
+ case e.socket_error
348
+ when EOFError
349
+ # The server may have closed an idle connection, but only
350
+ # half-way. In this scenario, Excon will receive an EOFError
351
+ # when attempting to post to the connection. We'll allow one
352
+ # retry after resetting the connection.
353
+ # We're not using Excon's idempotent retries because we only
354
+ # want to retry in the specific case of this exception, not
355
+ # retry all errors. Setting Excons :retry_errors param did not
356
+ # succeed in catching this situation.
357
+ client.reset
358
+ retry if attempts < 2
359
+ else
360
+ raise e
361
+ end
362
+ end
363
+ end
339
364
  end
340
365
  end
@@ -1,3 +1,3 @@
1
1
  module Libhoney
2
- VERSION = '1.19.0'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
data/libhoney.gemspec CHANGED
@@ -20,22 +20,22 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.required_ruby_version = '>= 2.2.0'
23
+ spec.required_ruby_version = '>= 2.4.0'
24
24
 
25
25
  spec.add_development_dependency 'bump', '~> 0.5'
26
26
  spec.add_development_dependency 'bundler'
27
27
  spec.add_development_dependency 'lockstep'
28
28
  spec.add_development_dependency 'minitest', '~> 5.0'
29
29
  spec.add_development_dependency 'minitest-reporters'
30
- spec.add_development_dependency 'rake', '~> 12.3'
31
- spec.add_development_dependency 'rubocop', '< 0.69'
30
+ spec.add_development_dependency 'rake', '~> 13.0'
31
+ spec.add_development_dependency 'rubocop', '1.12.1'
32
32
  spec.add_development_dependency 'sinatra'
33
33
  spec.add_development_dependency 'sinatra-contrib'
34
- spec.add_development_dependency 'spy', '1.0.0'
34
+ spec.add_development_dependency 'spy', '~> 1.0'
35
35
  spec.add_development_dependency 'webmock', '~> 3.4'
36
36
  spec.add_development_dependency 'yard'
37
37
  spec.add_development_dependency 'yardstick', '~> 0.9'
38
38
  spec.add_dependency 'addressable', '~> 2.0'
39
39
  spec.add_dependency 'excon'
40
- spec.add_dependency 'http', '>= 2.0', '< 5.0'
40
+ spec.add_dependency 'http', '>= 2.0', '< 6.0'
41
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libhoney
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Honeycomb.io Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-23 00:00:00.000000000 Z
11
+ date: 2022-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bump
@@ -86,28 +86,28 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '12.3'
89
+ version: '13.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '12.3'
96
+ version: '13.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "<"
101
+ - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: '0.69'
103
+ version: 1.12.1
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "<"
108
+ - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: '0.69'
110
+ version: 1.12.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: sinatra
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -140,16 +140,16 @@ dependencies:
140
140
  name: spy
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '='
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.0.0
145
+ version: '1.0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '='
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.0.0
152
+ version: '1.0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: webmock
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -229,7 +229,7 @@ dependencies:
229
229
  version: '2.0'
230
230
  - - "<"
231
231
  - !ruby/object:Gem::Version
232
- version: '5.0'
232
+ version: '6.0'
233
233
  type: :runtime
234
234
  prerelease: false
235
235
  version_requirements: !ruby/object:Gem::Requirement
@@ -239,7 +239,7 @@ dependencies:
239
239
  version: '2.0'
240
240
  - - "<"
241
241
  - !ruby/object:Gem::Version
242
- version: '5.0'
242
+ version: '6.0'
243
243
  description: Ruby gem for sending data to Honeycomb
244
244
  email: support@honeycomb.io
245
245
  executables: []
@@ -250,19 +250,32 @@ files:
250
250
  - ".circleci/setup-rubygems.sh"
251
251
  - ".editorconfig"
252
252
  - ".github/CODEOWNERS"
253
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
254
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
255
+ - ".github/ISSUE_TEMPLATE/question-discussion.md"
256
+ - ".github/ISSUE_TEMPLATE/security-vulnerability-report.md"
257
+ - ".github/PULL_REQUEST_TEMPLATE.md"
253
258
  - ".github/dependabot.yml"
254
259
  - ".github/workflows/add-to-project.yml"
255
260
  - ".github/workflows/apply-labels.yml"
261
+ - ".github/workflows/re-triage.yml"
262
+ - ".github/workflows/stale.yml"
256
263
  - ".gitignore"
257
264
  - ".rubocop.yml"
258
265
  - ".rubocop_todo.yml"
259
266
  - CHANGELOG.md
267
+ - CODE_OF_CONDUCT.md
268
+ - CONTRIBUTING.md
260
269
  - CONTRIBUTORS
261
270
  - Gemfile
262
271
  - LICENSE
263
272
  - NOTICE
273
+ - OSSMETADATA
264
274
  - README.md
275
+ - RELEASING.md
265
276
  - Rakefile
277
+ - SECURITY.md
278
+ - SUPPORT.md
266
279
  - example/factorial.rb
267
280
  - lib/libhoney.rb
268
281
  - lib/libhoney/builder.rb
@@ -295,14 +308,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
295
308
  requirements:
296
309
  - - ">="
297
310
  - !ruby/object:Gem::Version
298
- version: 2.2.0
311
+ version: 2.4.0
299
312
  required_rubygems_version: !ruby/object:Gem::Requirement
300
313
  requirements:
301
314
  - - ">="
302
315
  - !ruby/object:Gem::Version
303
316
  version: '0'
304
317
  requirements: []
305
- rubygems_version: 3.1.6
318
+ rubygems_version: 3.2.32
306
319
  signing_key:
307
320
  specification_version: 4
308
321
  summary: send data to Honeycomb