Sha256: 7e52e87059c166cf7041048591734c31b73d95997da2faae8c1a75350c8ce2ed
Contents?: true
Size: 998 Bytes
Versions: 48
Compression:
Stored size: 998 Bytes
Contents
require 'honeybadger' module Honeybadger module Rack class MetricsReporter GC_TIME_METRIC = 'app.gc.time'.freeze GC_COLLECTIONS_METRIC = 'app.gc.collections'.freeze def initialize(app, config) @app = app @config = config end def call(env) start = Time.now track_gc? and GC::Profiler.clear status, headers, body = app.call(env) duration = (Time.now - start) * 1000 report_metrics(status, duration) [status, headers, body] end private attr_reader :app, :config def track_gc? config[:'metrics.gc_profiler'] end def report_metrics(status, duration) Agent.timing("app.request.#{status}", duration) if track_gc? && GC::Profiler.total_time > 0 Agent.timing(GC_TIME_METRIC, GC::Profiler.total_time * 1000) Agent.increment(GC_COLLECTIONS_METRIC, GC::Profiler.result[/\d+/].to_i) end end end end end
Version data entries
48 entries across 48 versions & 2 rubygems