Skip to content

Commit ce11622

Browse files
authored
Merge pull request kubernetes#84522 from liu-cong/plugin
Add scheduler plugin execution duration metric.
2 parents 055daaf + af6a816 commit ce11622

File tree

8 files changed

+527
-97
lines changed

8 files changed

+527
-97
lines changed

pkg/scheduler/framework/v1alpha1/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ go_library(
66
"cycle_state.go",
77
"framework.go",
88
"interface.go",
9+
"metrics_recorder.go",
910
"registry.go",
1011
"waiting_pods_map.go",
1112
],
@@ -25,6 +26,7 @@ go_library(
2526
"//staging/src/k8s.io/client-go/informers:go_default_library",
2627
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
2728
"//staging/src/k8s.io/client-go/util/workqueue:go_default_library",
29+
"//staging/src/k8s.io/component-base/metrics:go_default_library",
2830
"//vendor/k8s.io/klog:go_default_library",
2931
"//vendor/sigs.k8s.io/yaml:go_default_library",
3032
],

pkg/scheduler/framework/v1alpha1/cycle_state.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ type StateKey string
4444
type CycleState struct {
4545
mx sync.RWMutex
4646
storage map[StateKey]StateData
47+
// if recordFrameworkMetrics is true, framework metrics will be recorded for this cycle.
48+
recordFrameworkMetrics bool
4749
}
4850

4951
// NewCycleState initializes a new CycleState and returns its pointer.
@@ -53,6 +55,22 @@ func NewCycleState() *CycleState {
5355
}
5456
}
5557

58+
// ShouldRecordFrameworkMetrics returns whether framework metrics should be recorded.
59+
func (c *CycleState) ShouldRecordFrameworkMetrics() bool {
60+
if c == nil {
61+
return false
62+
}
63+
return c.recordFrameworkMetrics
64+
}
65+
66+
// SetRecordFrameworkMetrics sets recordFrameworkMetrics to the given value.
67+
func (c *CycleState) SetRecordFrameworkMetrics(flag bool) {
68+
if c == nil {
69+
return
70+
}
71+
c.recordFrameworkMetrics = flag
72+
}
73+
5674
// Clone creates a copy of CycleState and returns its pointer. Clone returns
5775
// nil if the context being cloned is nil.
5876
func (c *CycleState) Clone() *CycleState {

0 commit comments

Comments
 (0)