Sha256: 71ca7a401cfa84478568e4acb42a852443d602917295ce45fa91062128126b13
Contents?: true
Size: 778 Bytes
Versions: 2
Compression:
Stored size: 778 Bytes
Contents
# frozen_string_literal: true require "anycable/middleware" module Yabeda module AnyCable # Instrumentation middleware that wraps every RPC command execution class Middleware < ::AnyCable::Middleware def call(rpc_method_name, request, _metadata = nil) started = Process.clock_gettime(Process::CLOCK_MONOTONIC) (response = yield) ensure elapsed = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - started).round(4) labels = { method: rpc_method_name.to_s, status: response.status.to_s } labels[:command] = request.respond_to?(:command) ? request.command : "" ::Yabeda.anycable.rpc_call_count.increment(labels) ::Yabeda.anycable.rpc_call_runtime.measure(labels, elapsed) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yabeda-anycable-0.1.1 | lib/yabeda/anycable/middleware.rb |
yabeda-anycable-0.1.0 | lib/yabeda/anycable/middleware.rb |