Sha256: 1c7531224170f21a7653213b56d1110e8b9d09965761b6a2b72567df17d26253
Contents?: true
Size: 807 Bytes
Versions: 2
Compression:
Stored size: 807 Bytes
Contents
module FluentLoggerStatistics class App include Rack::Utils def initialize(fluent_loggers) @fluent_loggers = fluent_loggers end ACCEPT_METHODS = ['GET'].freeze def call(env) unless ACCEPT_METHODS.include?(env['REQUEST_METHOD']) return [404, {'Content-Type' => 'text/plain'}, []] end status = 200 header = {'Content-Type' => 'application/json'} stats = @fluent_loggers.map{|k,v| bytesize = v.pending_bytesize limit_bytesize = v.limit usage_rate = bytesize / limit_bytesize.to_f [k, { buffer_bytesize: bytesize, buffer_limit: limit_bytesize, buffer_usage_rate: usage_rate }] }.to_h body = [ stats.to_json ] [status, header, body] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fluent_logger_statistics-0.4.0 | lib/fluent_logger_statistics/app.rb |
fluent_logger_statistics-0.3.0 | lib/fluent_logger_statistics/app.rb |