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 Prometheus metrics #419

Merged
merged 1 commit into from
Nov 27, 2024
Merged

Add Prometheus metrics #419

merged 1 commit into from
Nov 27, 2024

Conversation

DrJosh9000
Copy link
Contributor

@DrJosh9000 DrJosh9000 commented Nov 14, 2024

What

Adds a Prometheus metrics endpoint, and a whole heap of metrics.

Why

Fixes #102.

Addresses the metric part of #278.

Among other reasons, extra observability into the controller will likely be needed to keep digging into #302.

Show me the charts

Two ways to get the number of jobs the deduper thinks is running:
Screenshot 2024-11-27 at 1 28 01 PM
Screenshot 2024-11-27 at 1 29 36 PM

Available limiter tokens:
Screenshot 2024-11-27 at 1 30 16 PM

Median time between querying a job and scheduling it:
Screenshot 2024-11-27 at 1 31 15 PM

@DrJosh9000 DrJosh9000 force-pushed the add-prometheus-metrics branch from 68723ee to a1e9262 Compare November 14, 2024 06:53
@DrJosh9000 DrJosh9000 force-pushed the add-prometheus-metrics branch 13 times, most recently from 77b1e74 to aa1ef30 Compare November 26, 2024 05:47
@DrJosh9000 DrJosh9000 changed the title [WIP] Add Prometheus metrics Add Prometheus metrics Nov 26, 2024
@DrJosh9000 DrJosh9000 marked this pull request as ready for review November 26, 2024 05:51
@DrJosh9000 DrJosh9000 force-pushed the add-prometheus-metrics branch 7 times, most recently from 0e7b9d5 to b3bf2d5 Compare November 27, 2024 00:48
@DrJosh9000 DrJosh9000 force-pushed the add-prometheus-metrics branch from b3bf2d5 to 7542e8a Compare November 27, 2024 00:54
Copy link
Contributor

@CerealBoy CerealBoy left a comment

Choose a reason for hiding this comment

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

This is great! I had 1 inline question, and there's other similar examples that I didn't add the same question.

As an aside, have we thought about other providers / services besides prometheus? Would we be able to use OpenTelemetry to achieve the same thing without being tied specifically to prometheus?

Comment on lines +17 to +22
_ = promauto.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: promNamespace,
Subsystem: promSubsystem,
Name: "jobs_running",
Help: "Current number of running jobs according to deduper",
}, func() float64 { return float64(jobsRunningGaugeFunc()) })
Copy link
Contributor

Choose a reason for hiding this comment

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

With the _ = is this merely a template for adding the rest of the vars below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's _ merely because this gauge doesn't need to be referred to within the package later on - promauto registers the metric, then the value is obtained during metric scrape through the callback (unlike most of the other metrics, where the value is set or incremented or added or observed on the metric).

Copy link
Contributor

Choose a reason for hiding this comment

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

Excellent, thank you for the explanation!

@DrJosh9000
Copy link
Contributor Author

As an aside, have we thought about other providers / services besides prometheus?

Not particularly. I'm more familiar with Prometheus than anything else 🤷

Would we be able to use OpenTelemetry to achieve the same thing without being tied specifically to prometheus?

I believe so. The types of metrics defined here are a subset of the types supported in OTel. Moving across shouldn't be too difficult given the OTel Go SDK has a Prometheus Exporter.

@DrJosh9000 DrJosh9000 merged commit df28f42 into main Nov 27, 2024
1 check passed
@DrJosh9000 DrJosh9000 deleted the add-prometheus-metrics branch November 27, 2024 04:13
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.

Expose metrics
2 participants