libhoney 1.21.0 → 2.0.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: c346ba7e750c99063736cd641e10eb153f9a1326b1bf17231e7c89ad312d102a
4
+ data.tar.gz: 5f16185c3b43ce38f0323861244966ccc6df2404c5b7c05f712c530d25f193d6
5
5
  SHA512:
6
- metadata.gz: 7cbf429690cb10522b488f631be5b726e6973e3b1d73b660ac28f3d8186e7b88b392c6736252dc9e2a77bb2fb78a70bf8e678653edb12c8405a45bd693ec0e28
7
- data.tar.gz: 9b318c534cdeac671ea52e880ce9e8e047bc2b730eb9ab7e020c111dbfaedc19083cd152e8e506b3422ef36c3d9e719b87ac661d871bf8cd13d5c24d5b5d19fb
6
+ metadata.gz: 5c4ebb204f1f7fa8cbc602442d6672753d2395b53a9cbae3f4ca61e2a96fa17e54c2206c55cfdb7ec32e1349daa64f70cfffd755e957f2060ab7231791420bc5
7
+ data.tar.gz: 07be9a04ccb025acc0b9e05e0e1fea17a1bd5b694ef9ec0443b0e5638d3b9a024502e05d7d677d752920c81d36249008ed4f226f293c8f5b3dfa469c7ac5b528
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,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,15 @@
1
- # libhoney-rb changelog
1
+ ## [2.0.0] - 2021-10-07
2
+
3
+ ### 💥 Breaking Changes
4
+
5
+ - support dropped for Ruby 2.2 (#104) | [robbkidd](https://github.com/robbkidd)
6
+ - support dropped for Ruby 2.3 (#106) | [robbkidd](https://github.com/robbkidd)
7
+ - remove deprecated support for accepting an Array for client proxy_config (#112) | [robbkidd](https://github.com/robbkidd)
8
+
9
+ ### 🛠 Maintenance
10
+
11
+ - Change maintenance badge to maintained (#109) | [JamieDanielson](https://github.com/JamieDanielson)
12
+ - Adds Stalebot (#110) | [JamieDanielson](https://github.com/JamieDanielson)
2
13
 
3
14
  ## [1.21.0] - 2021-09-23
4
15
 
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
@@ -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}"
@@ -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
@@ -124,10 +124,7 @@ module Libhoney
124
124
  end
125
125
 
126
126
  @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
127
+ @batch_thread&.join(1.0) # limit the amount of time we'll wait for the thread to end
131
128
 
132
129
  # send @threads.length number of nils so each thread will fall out of send_loop
133
130
  @threads.length.times { @send_queue << nil }
@@ -305,7 +302,7 @@ module Libhoney
305
302
 
306
303
  def ensure_threads_running
307
304
  @lock.synchronize do
308
- @batch_thread = Thread.new { batch_loop } unless @batch_thread && @batch_thread.alive?
305
+ @batch_thread = Thread.new { batch_loop } unless @batch_thread&.alive?
309
306
  @threads.select!(&:alive?)
310
307
  @threads << Thread.new { send_loop } while @threads.length < @max_concurrent_batches
311
308
  end
@@ -1,3 +1,3 @@
1
1
  module Libhoney
2
- VERSION = '1.21.0'.freeze
2
+ VERSION = '2.0.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.0.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: 2021-10-07 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,7 @@ files:
258
258
  - ".github/dependabot.yml"
259
259
  - ".github/workflows/add-to-project.yml"
260
260
  - ".github/workflows/apply-labels.yml"
261
+ - ".github/workflows/stale.yml"
261
262
  - ".gitignore"
262
263
  - ".rubocop.yml"
263
264
  - ".rubocop_todo.yml"
@@ -306,14 +307,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
306
307
  requirements:
307
308
  - - ">="
308
309
  - !ruby/object:Gem::Version
309
- version: 2.2.0
310
+ version: 2.4.0
310
311
  required_rubygems_version: !ruby/object:Gem::Requirement
311
312
  requirements:
312
313
  - - ">="
313
314
  - !ruby/object:Gem::Version
314
315
  version: '0'
315
316
  requirements: []
316
- rubygems_version: 3.1.6
317
+ rubygems_version: 3.2.22
317
318
  signing_key:
318
319
  specification_version: 4
319
320
  summary: send data to Honeycomb