jgraichen / telegraf-ruby

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

Allow to exclude paths from Rack #25

Closed noma4i closed 11 months ago

noma4i commented 11 months ago

Main reason we need to exclude paths is the crazy amount of health checks or metrics flooding telegraf. Option for exclude_paths will prevent reporting on that endpoints

leshik commented 11 months ago

Thanks @noma4i. @jgraichen could you take a look at this, please? Ref #24

jgraichen commented 11 months ago

Thank you, @noma4i and @leshik!

Would it be an option for you to generalize that into a exclude: argument that takes a lambda as an argument so that this gem doesn't need to know about paths?

For example:

# Return `true` to skip the metric point for this request
my_filter = lambda { |env|
  req = Rack::Request.new(env)
  req.path =~ %r{^/(health|metric)} || req.params['admin'] == '1'
}

use ::Telegraf::Rack.new(series: 'rack', agent: agent, tags: {global: 'tag'}, exclude: my_filter)

You wouldn't be limited to path filters only and the gem wouldn't need an update to support other filters.

noma4i commented 11 months ago

It looks too explicit for rails.

franzliedke commented 11 months ago

This gem (and especially this config) isn't focused on Rails.

noma4i commented 11 months ago

This gem is very less code to support.

jgraichen commented 11 months ago

@noma4i I haven't had enough time to review again in the last few days, sorry!

Are you no longer interested in pursuing this merge request?

noma4i commented 11 months ago

WoW that was fast. This PR was closed so fast that I was not able to fix anything. Just wow.

jgraichen commented 11 months ago

@noma4i You closed the PR yourself last week. That's why I was asking. :grin:

image