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

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

Overview

JSON formatter for IO, expects ‘call` method accepting telemetry hash

Class Method Summary collapse

Class Method Details

.call(telemetry) ⇒ Object

NOTE: Replace dots with dashes for better support of AWS CloudWatch

Log Metric filters, as they don't support dots in key names.


17
18
19
20
21
22
23
24
# File 'lib/puma/plugin/telemetry/targets/io_target.rb', line 17

def self.call(telemetry)
  log = telemetry.transform_keys { |k| k.tr('.', '-') }

  log['name'] = 'Puma::Plugin::Telemetry'
  log['message'] = 'Publish telemetry'

  ::JSON.dump(log)
end