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

Dynamic labels for sidekiq jobs #274

Open
edenisn opened this issue Mar 16, 2023 · 3 comments
Open

Dynamic labels for sidekiq jobs #274

edenisn opened this issue Mar 16, 2023 · 3 comments

Comments

@edenisn
Copy link

edenisn commented Mar 16, 2023

Hi, thanks for this beautiful gem.
I see that we can added static labels in sidekiq job (on official page of a gem):
Custom labels can be added for individual jobs by defining a class method on the job class. These labels will be added to all Sidekiq metrics written by the job:

  class WorkerWithCustomLabels
    def self.custom_labels
      { my_label: 'value-here', other_label: 'second-val' }
    end

    def perform; end
  end

but, what about dynamic labels? How we can add those labels?

@SamSaffron
Copy link
Member

I think you would need to extend the class to support that. What exactly are you trying to achieve?

@edenisn
Copy link
Author

edenisn commented Mar 22, 2023

So, for example above with static label when we start sidekiq job - WorkerWithCustomLabels it will add two labels - my_label = 'value-here' and other_label = 'second-val', those labels are static.
But, in some cases we want to add dynamic labels, for example:

class SomeTestJob
  def perform(event_id)
    event = Event.find(event_id)
    label = event.type
  end  
end

and I want to set this label for this job with - label = event.type. Type of this label is not static - it's dynamic label.
And my question: how can we add those type of labels to Sidekiq jobs?
Thanks!

@edenisn
Copy link
Author

edenisn commented Mar 23, 2023

It's seems to me that it should look something like this yabeda-rb/yabeda#12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants