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

Limit the set of controller metrics #16

Open
Merff opened this issue Oct 16, 2020 · 2 comments
Open

Limit the set of controller metrics #16

Merff opened this issue Oct 16, 2020 · 2 comments

Comments

@Merff
Copy link

Merff commented Oct 16, 2020

Hi!
Is it possible to do that?
I tried smth like that

Yabeda::Rails.on_controller_action do |event, labels|
  next unless Rails.configuration.measured_actions.include? "#{labels[:controller]}##{labels[:action]}"
  ...

and

config.measured_actions = [
      'api/entry#index',
      'api/offers#index'
    ]

but not working, I see all controllers in /metrics

@Envek
Copy link
Member

Envek commented Oct 16, 2020

It is not possible at the moment.

Yabeda::Rails.on_controller_action is a hook to adding measure of new custom metrics and can't limit builtin ones.

For now you can fork this gem and experiment with adding some guard clauses (like next unless event.payload[:params]["controller"].in? %w[your whitelisted controllers]) between lines 42 and 43 of lib/yabeda/rails.rb, here:

ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args|
event = ActiveSupport::Notifications::Event.new(*args)

And you can add ability to configure it via AnywayConfig and make a Pull Request! 😉

@Merff
Copy link
Author

Merff commented Oct 16, 2021 via email

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

No branches or pull requests

2 participants