libhoney 1.21.0 → 2.2.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: e193211937c61bf221e8610d7324c173d90aefa2f5d08f706c0ea56dcbb1d971
4
- data.tar.gz: d235e368e4f1dc9b11a5a489fdff04c734a7804d57925394f515ac92a11ef0bf
3
+ metadata.gz: '0867b211b613819cb14a3d4001d4a119d94a889a4aa8090f05f9233309786b63'
4
+ data.tar.gz: '0810087e42caf6553f088bad7744e650f7061e76c4ea89a5dc6ff1bf334b1b7e'
5
5
  SHA512:
6
- metadata.gz: 7cbf429690cb10522b488f631be5b726e6973e3b1d73b660ac28f3d8186e7b88b392c6736252dc9e2a77bb2fb78a70bf8e678653edb12c8405a45bd693ec0e28
7
- data.tar.gz: 9b318c534cdeac671ea52e880ce9e8e047bc2b730eb9ab7e020c111dbfaedc19083cd152e8e506b3422ef36c3d9e719b87ac661d871bf8cd13d5c24d5b5d19fb
6
+ metadata.gz: 7b3a51a0211491964afa320c12c25c919ac82362f1e42a1dfbbd27f8e6d0c5d09089ed9c4517d32e34dd2d884a9e5891c9878dce73a4668255a413854defe1de
7
+ data.tar.gz: 98faec4862aabf78f61f3f92c7374ec3e55a15bd517b8f9f04f3909defd56b89feb47dc6268df659463e8f219582985923a212644619027f782ccc90e0ce2c42
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
@@ -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,4 +1,33 @@
1
- # libhoney-rb changelog
1
+ ## [2.2.0] - 2022-04-14
2
+
3
+ ### Added
4
+
5
+ - Add Environment and Services support (#123) | [@MikeGoldsmith](https://github.com/MikeGoldsmith)
6
+
7
+ ## [2.1.0] - 2022-02-02
8
+
9
+ ### Improvements
10
+
11
+ - 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)
12
+
13
+ ### Maintenance
14
+
15
+ - gh: add re-triage workflow (#117) | [vreynolds](https://github.com/vreynolds)
16
+ - Update dependabot to monthly (#116) | [vreynolds](https://github.com/vreynolds)
17
+ - empower apply-labels action to apply labels (#115) | [robbkidd](https://github.com/robbkidd)
18
+
19
+ ## [2.0.0] - 2021-10-07
20
+
21
+ ### 💥 Breaking Changes
22
+
23
+ - support dropped for Ruby 2.2 (#104) | [robbkidd](https://github.com/robbkidd)
24
+ - support dropped for Ruby 2.3 (#106) | [robbkidd](https://github.com/robbkidd)
25
+ - remove deprecated support for accepting an Array for client proxy_config (#112) | [robbkidd](https://github.com/robbkidd)
26
+
27
+ ### 🛠 Maintenance
28
+
29
+ - Change maintenance badge to maintained (#109) | [JamieDanielson](https://github.com/JamieDanielson)
30
+ - Adds Stalebot (#110) | [JamieDanielson](https://github.com/JamieDanielson)
2
31
 
3
32
  ## [1.21.0] - 2021-09-23
4
33
 
@@ -17,7 +46,7 @@
17
46
 
18
47
  ## 1.20.0
19
48
 
20
- ### Fixes
49
+ ### Fixes
21
50
 
22
51
  - Handle Timeout::Error in TransmissionClient (#95) | [Adam Pohorecki](https://github.com/psyho)
23
52
 
@@ -63,7 +92,7 @@
63
92
 
64
93
  - Don't moneypatch Class (#70)
65
94
 
66
- ### Maintenance:
95
+ ### Maintenance:
67
96
 
68
97
  - Add lockfile to gitignore (#71)
69
98
 
data/OSSMETADATA CHANGED
@@ -1 +1 @@
1
- osslifecycle=maintenance
1
+ osslifecycle=maintained
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # libhoney
2
2
 
3
- [![OSS Lifecycle](https://img.shields.io/osslifecycle/honeycombio/libhoney-rb)](https://github.com/honeycombio/home/blob/main/honeycomb-oss-lifecycle-and-practices.md)
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
4
  [![CircleCI Build Status](https://circleci.com/gh/honeycombio/libhoney-rb.svg?style=svg)](https://circleci.com/gh/honeycombio/libhoney-rb)
5
5
  [![Gem Version](https://badge.fury.io/rb/libhoney.svg)](https://badge.fury.io/rb/libhoney)
6
6
 
7
7
  Ruby gem for sending events to [Honeycomb](https://www.honeycomb.io), a service for debugging your software in production.
8
8
 
9
- Requires Ruby 2.2 or greater.
9
+ Requires Ruby 2.3 or greater.
10
10
 
11
11
  - [Usage and Examples](https://docs.honeycomb.io/sdk/ruby/)
12
12
  - [API Reference](https://www.rubydoc.info/gems/libhoney)
@@ -20,15 +20,3 @@ open issues or a pull request with your change. Remember to add your name to the
20
20
  CONTRIBUTORS file!
21
21
 
22
22
  All contributions will be released under the Apache License 2.0.
23
-
24
- ### Releasing a new version
25
-
26
- CircleCI will automatically upload tagged releases to Rubygems. To release a new
27
- version, update the version using `bump`.
28
-
29
- ```
30
- bump patch # Or bump minor, etc.
31
- ```
32
-
33
- Then, after the version change has been merged into `main`, follow our usual instructions
34
- for tagging and updating the github release.
data/RELEASING.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Releasing
2
2
 
3
3
  - Update the version number in `lib/libhoney/version.rb`.
4
- - Run `bundle lock`.
5
- - Confirm the version number update appears in `Gemfile.lock`
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.
6
7
  - Update `CHANGELOG.md` with the changes since the last release.
7
8
  - Commit changes, push, and open a release preparation pull request for review.
8
9
  - Once the pull request is merged, fetch the updated `main` branch.
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
@@ -34,6 +34,7 @@ module Libhoney
34
34
  extend Forwardable
35
35
 
36
36
  API_HOST = 'https://api.honeycomb.io/'.freeze
37
+ DEFAULT_DATASET = 'unknown_dataset'.freeze
37
38
 
38
39
  # Instantiates libhoney and prepares it to send events to Honeycomb.
39
40
  #
@@ -55,13 +56,10 @@ module Libhoney
55
56
  # @param block_on_responses [Boolean] if true, block if there is no thread reading from the response queue
56
57
  # @param pending_work_capacity [Fixnum] defaults to 1000. If the queue of
57
58
  # pending events exceeds 1000, this client will start dropping events.
58
- # @param proxy_config [String, Array, nil] proxy connection information
59
+ # @param proxy_config [String, nil] proxy connection information
59
60
  # nil: (default, recommended) connection proxying will be determined from any http_proxy, https_proxy, and no_proxy environment
60
61
  # variables set for the process.
61
62
  # 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
63
  # rubocop:disable Metrics/ParameterLists
66
64
  def initialize(writekey: nil,
67
65
  dataset: nil,
@@ -78,17 +76,13 @@ module Libhoney
78
76
  proxy_config: nil)
79
77
  # rubocop:enable Metrics/ParameterLists
80
78
  # 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
79
+ raise 'libhoney: max_concurrent_batches must be greater than 0' if max_concurrent_batches < 1
80
+ raise 'libhoney: sample rate must be greater than 0' if sample_rate < 1
87
81
 
88
82
  @builder = Builder.new(self, nil)
89
83
 
90
84
  @builder.writekey = writekey
91
- @builder.dataset = dataset
85
+ @builder.dataset = get_dataset(dataset, writekey)
92
86
  @builder.sample_rate = sample_rate
93
87
  @builder.api_host = api_host
94
88
 
@@ -114,7 +108,7 @@ module Libhoney
114
108
 
115
109
  # Nuke the queue and wait for inflight requests to complete before returning.
116
110
  # If you set drain=false, all queued requests will be dropped on the floor.
117
- def close(drain = true)
111
+ def close(drain = true) # rubocop:disable Style/OptionalBooleanParameter
118
112
  return @transmission.close(drain) if @transmission
119
113
 
120
114
  0
@@ -244,18 +238,20 @@ module Libhoney
244
238
  end
245
239
 
246
240
  case transmission
241
+ # rubocop:disable Style/GuardClause, Style/RedundantReturn
247
242
  when NilClass # the default value for new clients
248
243
  return TransmissionClient.new(**transmission_client_params)
249
244
  when Class
250
245
  # if a class has been provided, attempt to instantiate it with parameters given to the client
251
246
  t = transmission.new(**transmission_client_params)
252
- if quacks_like_a_transmission?(t) # rubocop:disable Style/GuardClause
247
+ if quacks_like_a_transmission?(t)
253
248
  return t
254
249
  else
255
250
  warn "#{t.class.name}: does not appear to behave like a transmission, disabling sending events"
256
251
  return NullTransmissionClient.new
257
252
  end
258
253
  end
254
+ # rubocop:enable Style/GuardClause, Style/RedundantReturn
259
255
  end
260
256
 
261
257
  def quacks_like_a_transmission?(transmission)
@@ -269,25 +265,35 @@ module Libhoney
269
265
  when String
270
266
  URI.parse(config)
271
267
  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
268
+ error_message = <<~MESSAGE
269
+ #{self.class.name}: the optional proxy_config parameter requires a String value; Array is no longer supported.
270
+ To resolve:
271
+ + recommended: set http/https_proxy environment variables, which take precedence over any option set here, then remove proxy_config parameter from client initialization
272
+ + set proxy_config to a String containing the forwarding proxy URI (only used if http/https_proxy environment variables are not set)
273
+ MESSAGE
274
+ raise error_message
288
275
  end
289
276
  rescue URI::Error => e
290
277
  warn "#{self.class.name}: unable to parse proxy_config. Detail: #{e.class}: #{e.message}"
291
278
  end
279
+
280
+ def get_dataset(dataset, write_key)
281
+ return dataset if classic_write_key?(write_key)
282
+
283
+ if dataset.nil? || dataset.empty?
284
+ warn "nil or empty dataset - sending data to '#{DEFAULT_DATASET}'"
285
+ dataset = DEFAULT_DATASET
286
+ end
287
+ trimmed = dataset.strip
288
+ if dataset != trimmed
289
+ warn "dataset contained leading or trailing whitespace - sending data to '#{trimmed}'"
290
+ dataset = trimmed
291
+ end
292
+ dataset
293
+ end
294
+
295
+ def classic_write_key?(write_key)
296
+ write_key.nil? || write_key.length == 32
297
+ end
292
298
  end
293
299
  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 }
@@ -305,7 +298,7 @@ module Libhoney
305
298
 
306
299
  def ensure_threads_running
307
300
  @lock.synchronize do
308
- @batch_thread = Thread.new { batch_loop } unless @batch_thread && @batch_thread.alive?
301
+ @batch_thread = Thread.new { batch_loop } unless @batch_thread&.alive?
309
302
  @threads.select!(&:alive?)
310
303
  @threads << Thread.new { send_loop } while @threads.length < @max_concurrent_batches
311
304
  end
@@ -340,5 +333,33 @@ module Libhoney
340
333
  h[api_host] = client
341
334
  end
342
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
343
364
  end
344
365
  end
@@ -1,3 +1,3 @@
1
1
  module Libhoney
2
- VERSION = '1.21.0'.freeze
2
+ VERSION = '2.2.0'.freeze
3
3
  end
data/libhoney.gemspec CHANGED
@@ -20,7 +20,7 @@ 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'
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'minitest', '~> 5.0'
29
29
  spec.add_development_dependency 'minitest-reporters'
30
30
  spec.add_development_dependency 'rake', '~> 13.0'
31
- spec.add_development_dependency 'rubocop', '< 0.69'
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
34
  spec.add_development_dependency 'spy', '~> 1.0'
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.21.0
4
+ version: 2.2.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-09-23 00:00:00.000000000 Z
11
+ date: 2022-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bump
@@ -98,16 +98,16 @@ dependencies:
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
@@ -258,6 +258,8 @@ files:
258
258
  - ".github/dependabot.yml"
259
259
  - ".github/workflows/add-to-project.yml"
260
260
  - ".github/workflows/apply-labels.yml"
261
+ - ".github/workflows/re-triage.yml"
262
+ - ".github/workflows/stale.yml"
261
263
  - ".gitignore"
262
264
  - ".rubocop.yml"
263
265
  - ".rubocop_todo.yml"
@@ -306,14 +308,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
306
308
  requirements:
307
309
  - - ">="
308
310
  - !ruby/object:Gem::Version
309
- version: 2.2.0
311
+ version: 2.4.0
310
312
  required_rubygems_version: !ruby/object:Gem::Requirement
311
313
  requirements:
312
314
  - - ">="
313
315
  - !ruby/object:Gem::Version
314
316
  version: '0'
315
317
  requirements: []
316
- rubygems_version: 3.1.6
318
+ rubygems_version: 3.3.11
317
319
  signing_key:
318
320
  specification_version: 4
319
321
  summary: send data to Honeycomb