-
Notifications
You must be signed in to change notification settings - Fork 41
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package deduper | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promauto" | ||
) | ||
|
||
const ( | ||
promNamespace = "buildkite" | ||
promSubsystem = "deduper" | ||
) | ||
|
||
// Overridden by New to return len(inFlight). | ||
var jobsRunningGaugeFunc = func() int { return 0 } | ||
|
||
var ( | ||
_ = 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()) }) | ||
|
||
jobHandlerCallsCounter = promauto.NewCounter(prometheus.CounterOpts{ | ||
Namespace: promNamespace, | ||
Subsystem: promSubsystem, | ||
Name: "job_handler_calls_total", | ||
Help: "Count of jobs that were passed to the next handler in the chain", | ||
}) | ||
jobHandlerErrorCounter = promauto.NewCounter(prometheus.CounterOpts{ | ||
Namespace: promNamespace, | ||
Subsystem: promSubsystem, | ||
Name: "job_handler_errors_total", | ||
Help: "Count of jobs that weren't scheduled because the next handler in the chain returned an error", | ||
}) | ||
|
||
onAddEventCounter = promauto.NewCounter(prometheus.CounterOpts{ | ||
Namespace: promNamespace, | ||
Subsystem: promSubsystem, | ||
Name: "onadd_events_total", | ||
Help: "Count of OnAdd informer events", | ||
}) | ||
onUpdateEventCounter = promauto.NewCounter(prometheus.CounterOpts{ | ||
Namespace: promNamespace, | ||
Subsystem: promSubsystem, | ||
Name: "onupdate_event_total", | ||
Help: "Count of OnUpdate informer events", | ||
}) | ||
onDeleteEventCounter = promauto.NewCounter(prometheus.CounterOpts{ | ||
Namespace: promNamespace, | ||
Subsystem: promSubsystem, | ||
Name: "ondelete_events_total", | ||
Help: "Count of OnDelete informer events", | ||
}) | ||
|
||
jobsMarkedRunningCounter = promauto.NewCounterVec(prometheus.CounterOpts{ | ||
Namespace: promNamespace, | ||
Subsystem: promSubsystem, | ||
Name: "jobs_marked_running_total", | ||
Help: "Count of times a job was added to inFlight", | ||
}, []string{"source"}) | ||
jobsUnmarkedRunningCounter = promauto.NewCounterVec(prometheus.CounterOpts{ | ||
Namespace: promNamespace, | ||
Subsystem: promSubsystem, | ||
Name: "jobs_unmarked_running_total", | ||
Help: "Count of times a job was removed from inFlight", | ||
}, []string{"source"}) | ||
jobsAlreadyRunningCounter = promauto.NewCounterVec(prometheus.CounterOpts{ | ||
Namespace: promNamespace, | ||
Subsystem: promSubsystem, | ||
Name: "jobs_already_running_total", | ||
Help: "Count of times a job was already present in inFlight", | ||
}, []string{"source"}) | ||
jobsAlreadyNotRunningCounter = promauto.NewCounterVec(prometheus.CounterOpts{ | ||
Namespace: promNamespace, | ||
Subsystem: promSubsystem, | ||
Name: "jobs_already_not_running_total", | ||
Help: "Count of times a job was already missing from inFlight", | ||
}, []string{"source"}) | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
With the
_ =
is this merely a template for adding the rest of the vars below?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.
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).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.
Excellent, thank you for the explanation!