jgraichen / telegraf-ruby

Send events from Ruby to a Telegraf agent
GNU Lesser General Public License v3.0
13 stars 7 forks source link

Can Sidekiq/ActiveJob agent reuse config from application.rb? #12

Closed machty closed 3 years ago

machty commented 3 years ago

I have config.telegraf.connect = "udp://localhost:61022" in my config/application.rb; is there any way to just the Sidekiq middleware use the same agent configuration from config/application.rb? If not, I have to copy the "udp://localhost:61022" everywhere else, which seems weird, but maybe I'm thinking about it wrong.

jgraichen commented 3 years ago

An initializer creates a telegraf agent and stores it in app.config.telegraf.agent. This agent is used when installing the sidekiq middleware in another initializer.

Are you doing some manual install? The sidekiq middleware should be automatically installed if used inside in a Rails application.

jgraichen commented 3 years ago

In a Rails application, it should be enough to add the require statements to config/application.rb:

# ...

require 'telegraf/rails'

module MyApp
  class Application < Rails::Application
    # ...
machty commented 3 years ago

Oh, no I'm using Rails. I misread the docs and figured I still needed to do the Sidekiq chain config.

Let me try getting rid of the Sidekiq chaining code to see if it's all working.

machty commented 3 years ago

Yeah it worked, just was surprised that my "background" metric was renamed to "sidekiq", so I made this PR: #13.

Man, if people know what's good for them I'd expect this repo to have 400 stars by July.