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

Adds delay to Sidekiq metrics #418

Closed
gottfrois opened this issue May 9, 2018 · 8 comments
Closed

Adds delay to Sidekiq metrics #418

gottfrois opened this issue May 9, 2018 · 8 comments
Assignees
Labels
community Was opened by a community member feature-request A request for a new feature or change to an existing one integrations Involves tracing integrations

Comments

@gottfrois
Copy link
Contributor

Hey guys,

I've been trying to add a delay metric to Sidekiq which would represent the time spent for a job waiting in queue.
I've forked the gem and added the following code:

image

But I actually don't see those metrics in the metric explorer on Datadog nor the existing one like sidekiq.job.id or sidekiq.job.retry

image

So i'm not sure how/where those metrics are available. Can you help?
Thanks

@delner
Copy link
Contributor

delner commented May 9, 2018

@gottfrois Really like the idea here! Tags work a little differently than metrics however; what you added above should appear as tags on each of the Sidekiq traces your application is producing, if you highlight the sidekiq.job span. I don't believe these values will be aggregated or displayed in the Metrics Explorer.

@gottfrois
Copy link
Contributor Author

@delner oh ok i got this wrong!
So should delay be a tag or an actual metric?

@gottfrois
Copy link
Contributor Author

@delner you were right, i see the new delay field in the span trace directly. Any idea how I can actually create a real metric out of it? Also, how would it integrate within the APM dashboards?

@delner
Copy link
Contributor

delner commented May 11, 2018

@gottfrois I think most of our metrics are handled through our metrics gem https://github.com/DataDog/dogstatsd-ruby or https://github.com/DataDog/dogapi-rb.

As far as integrating that directly into the tracing portion of the code, off the top of my head, I might suggest using the Processing Pipeline to listen into these spans, then taking advantage of that to send off metrics using the metrics gem for each tag you'd like to measure.

Might look something like this in your datadog.rb initializer file or equivalent:

Datadog::Pipeline.before_flush(
  Datadog::Pipeline::SpanProcessor.new do |span|
    if span.name == 'sidekiq.job'
      # Send your metric here:
      # value = span.get_tag('sidekiq.job.delay').to_f
    end
  end
)

Give that a shot and let me know if that works for you!

@gottfrois
Copy link
Contributor Author

@delner thanks a log for the code snippet. I do believe it works but i cannot confirm because i think i reached the limit of the number of custom metrics i can send on datadog :(

What's your input on custom metrics usage here? For example, the sidekiq trace uses a lot of custom metrics quotas:

image

Due to the number of tags and ressources i guess?

@gottfrois
Copy link
Contributor Author

Nevertheless i think i could submit a PR here to add those new metrics:

  • delay
  • started_at
  • finished_at
  • enqueued_at

image

What do you think?

@delner
Copy link
Contributor

delner commented May 11, 2018

Regarding custom metrics, admittedly, I'm not sure I can give you a good answer myself. I think the best I can offer right now is checking out our documentation on custom metrics, which hopefully has the details you need.

As for adding those datapoints to the Sidekiq tracing code, a PR that adds those basic values as tags (as opposed to metrics) sounds good to me.

@delner delner self-assigned this May 31, 2018
@delner delner added integrations Involves tracing integrations feature-request A request for a new feature or change to an existing one community Was opened by a community member labels May 31, 2018
@delner
Copy link
Contributor

delner commented Jun 27, 2018

This was released as a part of 0.13.0. Thanks for your contribution!

@delner delner closed this as completed Jun 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Was opened by a community member feature-request A request for a new feature or change to an existing one integrations Involves tracing integrations
Projects
None yet
Development

No branches or pull requests

2 participants