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

Add custom prometheus metrics #5422

Merged
merged 8 commits into from
May 29, 2024
Merged

Conversation

govindkrjoshi
Copy link
Contributor

No description provided.

class RefreshReportingViews
prepend SentryHandler
include ActiveSupport::Benchmarkable
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Comment on lines -117 to +124
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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

config/initializers/prometheus.rb Outdated Show resolved Hide resolved
config/initializers/prometheus.rb Outdated Show resolved Hide resolved
govindkrjoshi and others added 2 commits May 16, 2024 12:49
Co-authored-by: Atharva Raykar <24277692+tfidfwastaken@users.noreply.github.com>
@govindkrjoshi govindkrjoshi enabled auto-merge (squash) May 29, 2024 10:15
@govindkrjoshi govindkrjoshi merged commit e378128 into master May 29, 2024
1 check passed
@govindkrjoshi govindkrjoshi deleted the add-custom-prometheus-metrics branch May 29, 2024 10:47
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.

None yet

2 participants