diff --git a/CHANGELOG.md b/CHANGELOG.md index a1ffa0b..f1d7576 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.2] + +- Add Puma 6 compatibility ## [1.1.1] Public release. diff --git a/Gemfile.lock b/Gemfile.lock index 387136c..5be8418 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,8 @@ PATH remote: . specs: - puma-plugin-telemetry (1.1.1) - puma (>= 5.0) + puma-plugin-telemetry (1.1.2) + puma (< 7) GEM remote: https://rubygems.org/ @@ -14,7 +14,7 @@ GEM parallel (1.22.1) parser (3.1.2.0) ast (~> 2.4.1) - puma (5.6.4) + puma (6.0.1) nio4r (~> 2.0) rack (2.2.3.1) rainbow (3.1.1) @@ -64,4 +64,4 @@ DEPENDENCIES rubocop-performance (~> 1.9) BUNDLED WITH - 2.1.4 + 2.3.12 diff --git a/lib/puma/plugin/telemetry.rb b/lib/puma/plugin/telemetry.rb index e599853..235ecb2 100644 --- a/lib/puma/plugin/telemetry.rb +++ b/lib/puma/plugin/telemetry.rb @@ -63,13 +63,14 @@ def socket_telemetry(telemetry, launcher) # module PluginInstanceMethods def start(launcher) + @launcher = launcher + unless Puma::Plugin::Telemetry.config.enabled? - launcher.events.log 'plugin=telemetry msg="disabled, exiting..."' + log_writer.log 'plugin=telemetry msg="disabled, exiting..."' return end - @launcher = launcher - @launcher.events.log 'plugin=telemetry msg="enabled, setting up runner..."' + log_writer.log 'plugin=telemetry msg="enabled, setting up runner..."' in_background do sleep Puma::Plugin::Telemetry.config.initial_delay @@ -79,13 +80,13 @@ def start(launcher) def run! loop do - @launcher.events.debug 'plugin=telemetry msg="publish"' + log_writer.debug 'plugin=telemetry msg="publish"' call(Puma::Plugin::Telemetry.build(@launcher)) rescue Errno::EPIPE # Occurs when trying to output to STDOUT while puma is shutting down rescue StandardError => e - @launcher.events.error "plugin=telemetry err=#{e.class} msg=#{e.message.inspect}" + log_writer.error "plugin=telemetry err=#{e.class} msg=#{e.message.inspect}" ensure sleep Puma::Plugin::Telemetry.config.frequency end @@ -96,6 +97,16 @@ def call(telemetry) target.call(telemetry) end end + + private + + def log_writer + if Puma::Const::PUMA_VERSION.to_i < 6 + @launcher.events + else + @launcher.log_writer + end + end end end end diff --git a/lib/puma/plugin/telemetry/version.rb b/lib/puma/plugin/telemetry/version.rb index 193b0b0..116a5bb 100644 --- a/lib/puma/plugin/telemetry/version.rb +++ b/lib/puma/plugin/telemetry/version.rb @@ -3,7 +3,7 @@ module Puma class Plugin module Telemetry - VERSION = '1.1.1' + VERSION = '1.1.2' end end end diff --git a/puma-plugin-telemetry.gemspec b/puma-plugin-telemetry.gemspec index 8adfeb7..a9dfc68 100644 --- a/puma-plugin-telemetry.gemspec +++ b/puma-plugin-telemetry.gemspec @@ -39,5 +39,5 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ['lib'] - spec.add_dependency 'puma', '>= 5.0' + spec.add_dependency 'puma', '< 7' end