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

Improve default slug generation for sidekiq-scheduler #2184

Merged

Conversation

y-yagi
Copy link
Contributor

@y-yagi y-yagi commented Nov 29, 2023

Description

sidekiq-scheduler allows to use a class name as a schedule name directly as follows.

Namspeced::CancelAbandonedOrders:
  cron: '0 */5 * * * *'

In this case, a slug is shown as namspecedcancelabandonedorders on Sentry now. I think this isn't good for readability.
This PR converts :: to - as well as the cron default behavior of Crons mixin.

Related with: #2138.

Copy link

codecov bot commented Nov 29, 2023

Codecov Report

Merging #2184 (6271670) into master (4c8110c) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2184   +/-   ##
=======================================
  Coverage   97.31%   97.31%           
=======================================
  Files          99       99           
  Lines        3691     3692    +1     
=======================================
+ Hits         3592     3593    +1     
  Misses         99       99           
Components Coverage Δ
sentry-ruby 98.03% <100.00%> (ø)
sentry-rails 94.98% <ø> (ø)
sentry-sidekiq 94.53% <100.00%> (+0.03%) ⬆️
sentry-resque 92.06% <ø> (ø)
sentry-delayed_job 94.44% <ø> (ø)
sentry-opentelemetry 100.00% <ø> (ø)
Files Coverage Δ
sentry-ruby/lib/sentry/cron/monitor_check_ins.rb 100.00% <100.00%> (ø)
...-sidekiq/lib/sentry/sidekiq-scheduler/scheduler.rb 91.30% <100.00%> (+0.39%) ⬆️

@y-yagi y-yagi force-pushed the improve-cron-slug-with-sidekiq-scheduler branch 2 times, most recently from a0d0d0a to 0d0ebe3 Compare November 29, 2023 01:54
@y-yagi y-yagi changed the title Improve default slug generation on sidekiq-scheduler Improve default slug generation for sidekiq-scheduler Nov 29, 2023
@@ -44,9 +44,9 @@ def sentry_monitor_check_ins(slug: nil, monitor_config: nil)
prepend Patch
end

def sentry_monitor_slug
def sentry_monitor_slug(base_name = name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: let's keep calling it name as base_name could easily be associated basename methods in classes like Pathname and cause confusion. And IMO using karg will also make the API easier to use & maintain:

def sentry_monitor_slug(name: self.name)
end

Copy link
Member

@sl0thentr0py sl0thentr0py left a comment

Choose a reason for hiding this comment

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

thx @y-yagi please make the change that @st0012 requested, otherwise lgtm

`sidekiq-scheduler` allows to use a class name as a schedule name directly as follows.

```
Namspeced::CancelAbandonedOrders:
  cron: '0 */5 * * * *'
```

In this case, a slug is shown as `namspecedcancelabandonedorders` on Sentry.
I think this isn't good for readability.
This PR converts `::` to `-` as well as the cron default behavior of Crons mixin.

Related with: getsentry#2138.
@y-yagi y-yagi force-pushed the improve-cron-slug-with-sidekiq-scheduler branch from 0d0ebe3 to 6271670 Compare November 29, 2023 23:22
@y-yagi
Copy link
Contributor Author

y-yagi commented Nov 29, 2023

@st0012
Thanks for your review! I fixed your point!

@sl0thentr0py
Done!

Copy link
Collaborator

@st0012 st0012 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!

@st0012 st0012 merged commit b2111be into getsentry:master Nov 29, 2023
97 checks passed
@y-yagi y-yagi deleted the improve-cron-slug-with-sidekiq-scheduler branch November 29, 2023 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants