-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Improve metrics #3847
Open
tiithansen
wants to merge
7
commits into
actions:master
Choose a base branch
from
tiithansen:improve-metrics
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+130
−139
Open
Improve metrics #3847
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9a7febc
fix: Only observe duration if both times used in duration calculation…
tiithansen 0be5981
feat: Replace duration histograms with gauges which lost last executi…
tiithansen 00c8719
fix: Remove runner_name, runner_id and job_workflow_ref labels
tiithansen 83a75d7
fix: Consistently report same value for name label as the value used …
tiithansen c2eba45
feat: Add metric to export last duration job spent waiting in queue i…
tiithansen fb40b23
feat: Add new metric which would enable to join job to runner pod to …
tiithansen 8c32cd2
Merge branch 'master' into improve-metrics
tiithansen 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,10 +47,10 @@ var ( | |
labelKeyEventName, | ||
} | ||
|
||
completedJobsTotalLabels = append(jobLabels, labelKeyJobResult, labelKeyRunnerID, labelKeyRunnerName) | ||
jobExecutionDurationLabels = append(jobLabels, labelKeyJobResult, labelKeyRunnerID, labelKeyRunnerName) | ||
startedJobsTotalLabels = append(jobLabels, labelKeyRunnerID, labelKeyRunnerName) | ||
jobStartupDurationLabels = append(jobLabels, labelKeyRunnerID, labelKeyRunnerName) | ||
completedJobsTotalLabels = append(jobLabels, labelKeyJobResult, labelKeyRunnerID, labelKeyRunnerName) | ||
lastJobExecutionDurationLabels = append(jobLabels, labelKeyJobResult, labelKeyRunnerID, labelKeyRunnerName) | ||
startedJobsTotalLabels = append(jobLabels, labelKeyRunnerID, labelKeyRunnerName) | ||
lastJobStartupDurationLabels = append(jobLabels, labelKeyRunnerID, labelKeyRunnerName) | ||
) | ||
|
||
var ( | ||
|
@@ -144,75 +144,25 @@ var ( | |
completedJobsTotalLabels, | ||
) | ||
|
||
jobStartupDurationSeconds = prometheus.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
jobLastStartupDurationSeconds = prometheus.NewGaugeVec( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. worth adding a comment (in addition to commit message) why Gague is used, while ideally Histogram seems better data type - might avoid a lot of WTFs and wasting time basically reverting this change ;) |
||
prometheus.GaugeOpts{ | ||
Subsystem: githubScaleSetSubsystem, | ||
Name: "job_startup_duration_seconds", | ||
Help: "Time spent waiting for workflow job to get started on the runner owned by the scale set (in seconds).", | ||
Buckets: runtimeBuckets, | ||
Name: "job_last_startup_duration_seconds", | ||
Help: "The last duration spent waiting for workflow job to get started on the runner owned by the scale set (in seconds).", | ||
}, | ||
jobStartupDurationLabels, | ||
lastJobStartupDurationLabels, | ||
) | ||
|
||
jobExecutionDurationSeconds = prometheus.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
jobLastExecutionDurationSeconds = prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Subsystem: githubScaleSetSubsystem, | ||
Name: "job_execution_duration_seconds", | ||
Help: "Time spent executing workflow jobs by the scale set (in seconds).", | ||
Buckets: runtimeBuckets, | ||
Name: "job_last_execution_duration_seconds", | ||
Help: "The last duration spent executing workflow jobs by the scale set (in seconds).", | ||
}, | ||
jobExecutionDurationLabels, | ||
lastJobExecutionDurationLabels, | ||
) | ||
) | ||
|
||
var runtimeBuckets []float64 = []float64{ | ||
0.01, | ||
0.05, | ||
0.1, | ||
0.5, | ||
1, | ||
2, | ||
3, | ||
4, | ||
5, | ||
6, | ||
7, | ||
8, | ||
9, | ||
10, | ||
12, | ||
15, | ||
18, | ||
20, | ||
25, | ||
30, | ||
40, | ||
50, | ||
60, | ||
70, | ||
80, | ||
90, | ||
100, | ||
110, | ||
120, | ||
150, | ||
180, | ||
210, | ||
240, | ||
300, | ||
360, | ||
420, | ||
480, | ||
540, | ||
600, | ||
900, | ||
1200, | ||
1800, | ||
2400, | ||
3000, | ||
3600, | ||
} | ||
|
||
type baseLabels struct { | ||
scaleSetName string | ||
scaleSetNamespace string | ||
|
@@ -309,8 +259,8 @@ func NewExporter(config ExporterConfig) ServerPublisher { | |
idleRunners, | ||
startedJobsTotal, | ||
completedJobsTotal, | ||
jobStartupDurationSeconds, | ||
jobExecutionDurationSeconds, | ||
jobLastStartupDurationSeconds, | ||
jobLastExecutionDurationSeconds, | ||
) | ||
|
||
mux := http.NewServeMux() | ||
|
@@ -369,7 +319,7 @@ func (e *exporter) PublishJobStarted(msg *actions.JobStarted) { | |
|
||
if !msg.JobMessageBase.RunnerAssignTime.IsZero() && !msg.JobMessageBase.ScaleSetAssignTime.IsZero() { | ||
startupDuration := msg.JobMessageBase.RunnerAssignTime.Unix() - msg.JobMessageBase.ScaleSetAssignTime.Unix() | ||
jobStartupDurationSeconds.With(l).Observe(float64(startupDuration)) | ||
jobLastStartupDurationSeconds.With(l).Set(float64(startupDuration)) | ||
} | ||
} | ||
|
||
|
@@ -379,7 +329,7 @@ func (e *exporter) PublishJobCompleted(msg *actions.JobCompleted) { | |
|
||
if !msg.JobMessageBase.FinishTime.IsZero() && !msg.JobMessageBase.RunnerAssignTime.IsZero() { | ||
executionDuration := msg.JobMessageBase.FinishTime.Unix() - msg.JobMessageBase.RunnerAssignTime.Unix() | ||
jobExecutionDurationSeconds.With(l).Observe(float64(executionDuration)) | ||
jobLastExecutionDurationSeconds.With(l).Set(float64(executionDuration)) | ||
} | ||
} | ||
|
||
|
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.
typo in commit description?
vs
Also worth mentioning cardinality explosion and OOMs