Skip to content

Support for instrumenting polling? #311

Closed
@gjtorikian

Description

@gjtorikian

Hello! I was wondering if you'd accept a PR that implements instrumentation around polling. Something pretty much like this:

def with_polling_volume(&block)
  SolidQueue.instrument(:polling) do
    if SolidQueue.silence_polling? && ActiveRecord::Base.logger
      ActiveRecord::Base.logger.silence(&block)
    else
      yield
    end
  end
end

The reason being that even though silence_polling silences log statements, it does not silence instrumentation. That means that if the Rails app is hooked up to (for example) OpenTelemetry, the monitoring system receives thousands of BEGIN / COMMIT statements signifying nothing more than the polling is being checked. Can you tell when SQ was deployed? :P

graf

Currently, I have a monkey patch to support ignoring this:

module SolidQueue
  module Processes
    module PollerExtension
      def with_polling_volume
        OpenTelemetry::Instrumentation::PG.with_attributes("polling.solid_queue" => "true") do
          super
        end
      end
    end
  end
end

require "solid_queue/processes/poller_extension"

SolidQueue::Processes::Poller.prepend(SolidQueue::Processes::PollerExtension)

I can then instruct my collector to just filter out any polling.solid_queue events. This works, but it would be nice to remove my hack. 😆

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions