-
Notifications
You must be signed in to change notification settings - Fork 698
[SLI Metrics] kuberay_job_execution_duration_seconds #3488
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
Merged
kevin85421
merged 16 commits into
ray-project:master
from
troychiu:kuberay-job-execution-duration-seconds
Apr 30, 2025
Merged
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6696724
refactor ray job metrics
troychiu 37127a7
merge main
troychiu 3b228ef
[TEST] Improve test coverage for apiserver `pkg/manager` (#3386)
machichima 2e6aeab
[3/N] [Lint] Group imports by sections (#3430)
troychiu fa117cc
job execution duration
troychiu c72c9e9
merge main
troychiu a1ed979
refactor and add unit test
troychiu f34a3fb
refine description
troychiu 68fc3ba
refine comment
troychiu 92e177e
fix test
troychiu 7ed3761
refine metric description
troychiu 6005a72
code review
troychiu f10ad94
nit
troychiu 6012415
code review
troychiu 26dcf56
code review
troychiu 5b16829
fix test
troychiu 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 hidden or 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
52 changes: 52 additions & 0 deletions
52
ray-operator/controllers/ray/metrics/mocks/ray_job_metrics_mock.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -1,24 +1,45 @@ | ||
| package metrics | ||
|
|
||
| import ( | ||
| "strconv" | ||
|
|
||
| "github.com/prometheus/client_golang/prometheus" | ||
| ) | ||
|
|
||
| // RayJobMetricsCollector implements the prometheus.Collector interface to collect ray job metrics. | ||
| type RayJobMetricsCollector struct { | ||
| // Metrics | ||
| //go:generate mockgen -destination=mocks/ray_job_metrics_mock.go -package=mocks github.com/ray-project/kuberay/ray-operator/controllers/ray/metrics RayJobMetricsCollector | ||
| type RayJobMetricsCollector interface { | ||
troychiu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
troychiu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ObserveRayJobExecutionDuration(name, namespace, result string, retryCount int, duration float64) | ||
| } | ||
|
|
||
| // RayJobCollector implements the prometheus.Collector and RayJobMetricsCollector interface to collect ray job metrics. | ||
| type RayJobCollector struct { | ||
troychiu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| rayJobExecutionDurationSeconds *prometheus.GaugeVec | ||
| } | ||
|
|
||
| // NewRayJobMetricsCollector creates a new RayJobMetricsCollector instance. | ||
| func NewRayJobMetricsCollector() *RayJobMetricsCollector { | ||
| collector := &RayJobMetricsCollector{} | ||
| // NewRayJobCollector creates a new RayJobCollector instance. | ||
| func NewRayJobCollector() *RayJobCollector { | ||
| collector := &RayJobCollector{ | ||
| rayJobExecutionDurationSeconds: prometheus.NewGaugeVec( | ||
| prometheus.GaugeOpts{ | ||
| Name: "kuberay_job_execution_duration_seconds", | ||
| Help: "Duration from when the RayJob CR’s JobDeploymentStatus transitions from Initializing to either the Retrying state or a terminal state, such as Complete or Failed. The Retrying state indicates that the CR previously failed and that spec.backoffLimit is enabled.", | ||
| }, | ||
| []string{"name", "namespace", "job_deployment_result", "retry_count"}, | ||
troychiu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ), | ||
| } | ||
| return collector | ||
| } | ||
|
|
||
| // Describe implements prometheus.Collector interface Describe method. | ||
| func (c *RayJobMetricsCollector) Describe(_ chan<- *prometheus.Desc) { | ||
| func (c *RayJobCollector) Describe(ch chan<- *prometheus.Desc) { | ||
| c.rayJobExecutionDurationSeconds.Describe(ch) | ||
| } | ||
|
|
||
| // Collect implements prometheus.Collector interface Collect method. | ||
| func (c *RayJobMetricsCollector) Collect(_ chan<- prometheus.Metric) { | ||
| func (c *RayJobCollector) Collect(ch chan<- prometheus.Metric) { | ||
| c.rayJobExecutionDurationSeconds.Collect(ch) | ||
| } | ||
|
|
||
| func (c *RayJobCollector) ObserveRayJobExecutionDuration(name, namespace, jobDeploymentResult string, retryCount int, duration float64) { | ||
troychiu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
troychiu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| c.rayJobExecutionDurationSeconds.WithLabelValues(name, namespace, jobDeploymentResult, strconv.Itoa(retryCount)).Set(duration) | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.