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

Controller name case #26

Merged
merged 7 commits into from
Aug 3, 2023
Merged

Conversation

lewispb
Copy link
Contributor

@lewispb lewispb commented Jul 31, 2023

This allows configuration of the case of controller names in metrics.

Yabeda::Rails.config.controller_name_case = :camel

# rails_request_duration_seconds_bucket{action="show",controller="Accounts::Domains::TwoFactorAuthenticationsController",format="html",le="+Inf",method="get",status="200"} 1

Yabeda::Rails.config.controller_name_case = :snake # (default)

# rails_request_duration_seconds_bucket{action="show",controller="accounts/domains/two_factor_authentications",format="html",le="+Inf",method="get",status="200"} 1

This is important for us so we can correlate metrics between different systems, like logs and traces.

I introduced a new Yabeda::Rails::Event class to support this change, and so also extracted event-specific concerns from the long Yabeda::Rails.install! method into the new Event class.

Copy link
Member

@Envek Envek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your pull request! I'm fine with this addition in general, just need to clean up the pull request a bit.

P.S> And also please fix linters!

action: event.payload[:params]["action"],
status: Yabeda::Rails.event_status_code(event),
format: event.payload[:format],
method: event.payload[:method].downcase,
}
puts labels
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop debugging puts 😄

Suggested change
puts labels

.by(1)

described_class.config.controller_name_case = original_case
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Envek this violates the lint rule of a maximum of 5 lines in a spec. I'd suggest this is as compact as we should make this test. Do you want me to add a Rubocop exception comment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it here by nesting into context and moving setup code to around hook.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks @Envek. Been a while since I used Rspec!

I see the class comments now too - will make sure I use those in future.

@lewispb lewispb requested a review from Envek August 2, 2023 09:53
@Envek Envek merged commit 2f4fc1b into yabeda-rb:master Aug 3, 2023
@lewispb lewispb deleted the controller-name-case branch August 3, 2023 12:01
@Envek
Copy link
Member

Envek commented Aug 3, 2023

Released in 0.9.0, please enjoy.

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 this pull request may close these issues.

2 participants