Sha256: 2d026d01b9fa6bd54a710a1c5fcf10e83edf9cbf7e554d895ec63c7ae9b0c12a
Contents?: true
Size: 731 Bytes
Versions: 8
Compression:
Stored size: 731 Bytes
Contents
# frozen_string_literal: true module Salestation class Web < Module class StatsdMiddleware def initialize(app, statsd, metric:) @app = app @statsd = statsd @metric = metric end def call(env) start = Time.now status, header, body = @app.call env method = env['REQUEST_METHOD'] path = if route = env['sinatra.route'] route.split(' ').last else 'unknown-route' end @statsd.timing(@metric, (Time.now - start) * 1000, tags: [ "path:#{ path }", "method:#{ method }", "status:#{ status }" ]) [status, header, body] end end end end
Version data entries
8 entries across 8 versions & 1 rubygems