-
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 all 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
53 changes: 53 additions & 0 deletions
53
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,47 @@ | ||
| package metrics | ||
|
|
||
| import ( | ||
| "strconv" | ||
|
|
||
| "github.com/prometheus/client_golang/prometheus" | ||
|
|
||
| rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1" | ||
| ) | ||
|
|
||
| // 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 RayJobMetricsObserver | ||
| type RayJobMetricsObserver interface { | ||
| ObserveRayJobExecutionDuration(name, namespace string, jobDeploymentStatus rayv1.JobDeploymentStatus, retryCount int, duration float64) | ||
| } | ||
|
|
||
| // RayJobMetricsManager implements the prometheus.Collector and RayJobMetricsObserver interface to collect ray job metrics. | ||
| type RayJobMetricsManager struct { | ||
| rayJobExecutionDurationSeconds *prometheus.GaugeVec | ||
| } | ||
|
|
||
| // NewRayJobMetricsCollector creates a new RayJobMetricsCollector instance. | ||
| func NewRayJobMetricsCollector() *RayJobMetricsCollector { | ||
| collector := &RayJobMetricsCollector{} | ||
| // NewRayJobMetricsManager creates a new RayJobMetricsManager instance. | ||
| func NewRayJobMetricsManager() *RayJobMetricsManager { | ||
| collector := &RayJobMetricsManager{ | ||
| 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_status", "retry_count"}, | ||
| ), | ||
| } | ||
| return collector | ||
| } | ||
|
|
||
| // Describe implements prometheus.Collector interface Describe method. | ||
| func (c *RayJobMetricsCollector) Describe(_ chan<- *prometheus.Desc) { | ||
| func (c *RayJobMetricsManager) 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 *RayJobMetricsManager) Collect(ch chan<- prometheus.Metric) { | ||
| c.rayJobExecutionDurationSeconds.Collect(ch) | ||
| } | ||
|
|
||
| func (c *RayJobMetricsManager) ObserveRayJobExecutionDuration(name, namespace string, jobDeploymentStatus rayv1.JobDeploymentStatus, retryCount int, duration float64) { | ||
| c.rayJobExecutionDurationSeconds.WithLabelValues(name, namespace, string(jobDeploymentStatus), 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.