Sha256: df7a462e9a1f36d5e2c3ff1803c18ec05e66591c758b3d5032db5e45fe684994
Contents?: true
Size: 841 Bytes
Versions: 2
Compression:
Stored size: 841 Bytes
Contents
# frozen_string_literal: true require "rack/request" require "rack/utils" require "securerandom" require "yog" class Yog class Rack def initialize(app, **ctx) @app = app @ctx = ctx.merge(svc: "rack") end def call(env) now = Time.now req = ::Rack::Request.new(env) rid = (env["HTTP_X_REQUEST_ID"] ||= SecureRandom.uuid) Yog.context **@ctx, rid: rid do begin res = @app.call(env) ensure duration = (Time.now - now) * 1000 status, headers, * = res headers["X-Request-ID"] ||= rid Yog ::Rack::Utils::HTTP_STATUS_CODES[status], at: "finish", method: req.request_method, path: req.fullpath, status: status, duration: duration end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yog-0.4.0 | lib/yog/rack.rb |
yog-0.3.0 | lib/yog/rack.rb |