Class: Puma::Plugin::Telemetry::Targets::IOTarget

Inherits:
Object
  • Object
show all
Defined in:
lib/puma/plugin/telemetry/targets/io_target.rb

Overview

Simple IO Target, publishing metrics to STDOUT or logs

Defined Under Namespace

Classes: JSONFormatter

Instance Method Summary collapse

Constructor Details

#initialize(io: $stdout, formatter: :json) ⇒ IOTarget

Returns a new instance of IOTarget.



27
28
29
30
31
32
33
# File 'lib/puma/plugin/telemetry/targets/io_target.rb', line 27

def initialize(io: $stdout, formatter: :json)
  @io = io
  @formatter = case formatter
               when :json then JSONFormatter
               else formatter
               end
end

Instance Method Details

#call(telemetry) ⇒ Object



35
36
37
# File 'lib/puma/plugin/telemetry/targets/io_target.rb', line 35

def call(telemetry)
  @io.puts(@formatter.call(telemetry))
end