Sha256: 30d44bd0b18f05c39314e2b9b43825e06ef01b8b2f55c6c3ec87010a1680b663
Contents?: true
Size: 766 Bytes
Versions: 3
Compression:
Stored size: 766 Bytes
Contents
# frozen_string_literal: true module PrometheusExporter::Instrumentation class Sidekiq def initialize(client: nil) @client = client || PrometheusExporter::Client.default end def call(worker, msg, queue) success = false start = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) result = yield success = true result ensure duration = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start class_name = worker.class.to_s == 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper' ? msg['wrapped'] : worker.class.to_s @client.send_json( type: "sidekiq", name: class_name, success: success, duration: duration ) end end end
Version data entries
3 entries across 3 versions & 1 rubygems