jgraichen / telegraf-ruby

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

Sidekiq middleware can't find agent's method 'write' #26

Closed DmitriiRus37 closed 9 months ago

DmitriiRus37 commented 9 months ago

I have a peace of confuguration like this in setup.rb:

require 'telegraf'
require 'telegraf/sidekiq'

Sidekiq.configure_server do |config|
  config.logger = $log
  agent = ::Telegraf::Agent.new "udp://#{my_host}:#{my_port}"
  config.server_middleware do |chain|
    chain.add Telegraf::Sidekiq::Middleware,
              agent:  agent,
              series: 'my_series',
              tags:   { application: 'my_app' }
  end
end

and I receive:

2024-02-05T20:00:43+03:00 WARN NoMethodError: undefined method `write' for {:agent=>#<Telegraf::Agent:0x00007fb03962b128 @uri=#<URI::Generic udp://*host*:*port*>, @tags={}, @logger=nil>, :series=>"my_series", :tags=>{:application=>"my_app"}}:Hash

I can't found out what is wrong here. What did I miss?

ruby 3.2.2 telegraf 2.1.1 sidekiq 7.2.1

franzliedke commented 9 months ago

agent isn't a keyword argument.

Try this:

chain.add Telegraf::Sidekiq::Middleware,
              agent,
              series: 'my_series',
              tags:   { application: 'my_app' }