Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for instrumenting polling? #311

Closed
gjtorikian opened this issue Aug 29, 2024 · 3 comments · Fixed by #312
Closed

Support for instrumenting polling? #311

gjtorikian opened this issue Aug 29, 2024 · 3 comments · Fixed by #312

Comments

@gjtorikian
Copy link
Contributor

gjtorikian commented Aug 29, 2024

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. 😆

@rosa
Copy link
Member

rosa commented Aug 29, 2024

Ohhh! Yes, of course, go for it. And sorry about all that noise 🙉 😳 😅

@gjtorikian
Copy link
Contributor Author

No worries!

@gjtorikian
Copy link
Contributor Author

If anyone in the future comes here, the solution is now:

ActiveSupport::Notifications.subscribe("polling.solid_queue") do
  OpenTelemetry::Trace.current_span.add_attributes({
    "polling.solid_queue" => "true",
  })
end

I hope your world is nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants