-
Notifications
You must be signed in to change notification settings - Fork 34
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
Add custom prometheus metrics #5422
Conversation
class RefreshReportingViews | ||
prepend SentryHandler | ||
include ActiveSupport::Benchmarkable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question] Why are we not using the Benchmarkable mixin? It logs to the rails console by default, while the stdlib benchmark module does not. Are we specifically looking to avoid logging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we need the timing information to send to prometheus instead of logging it.
benchmark(name) do | ||
result = nil | ||
ms = Benchmark.ms do | ||
Datadog::Tracing.trace("refresh_matview", resource: operation) do |span| | ||
Statsd.instance.time(name) do | ||
yield | ||
end | ||
result = yield | ||
end | ||
end | ||
Statsd.instance.timing(name, ms) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, we only sent the time to run the code block to StatsD.
With this new change, we are now adding the time taken to run the Datadog::Tracing.trace
method along with the time taken to run the code block. Is this intended?
I am not able to think of a better way to do this, though. Moving the trace method outside will then include the benchmark call in the trace. Okay to leave it like this, since the time to call the trace method may not be a huge difference, and this bias would be consistent generally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I tried a couple of iterations to fix this, but this was the best I could do. I'm okay leaving it like this for the time being. Eventually we can get rid of the Datadog::Tracing bits.
Co-authored-by: Atharva Raykar <24277692+tfidfwastaken@users.noreply.github.com>
No description provided.