Skip to content

Commit

Permalink
add plugin type
Browse files Browse the repository at this point in the history
Signed-off-by: haoqing0110 <qhao@redhat.com>
  • Loading branch information
haoqing0110 committed Oct 26, 2023
1 parent 43bdfac commit 64bfc2b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/placement/controllers/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var (
StabilityLevel: k8smetrics.ALPHA,
Help: "How long in seconds a plugin runs for a placement.",
Buckets: k8smetrics.ExponentialBuckets(10e-7, 10, 10),
}, []string{"name", "plugin"})
}, []string{"name", "plugin_type", "plugin_name"})

metrics = []k8smetrics.Registerable{
schedulingDuration, bindDuration, PluginDuration,
Expand Down
12 changes: 10 additions & 2 deletions pkg/placement/controllers/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,17 @@ func TestMetrics(t *testing.T) {

startTime := c.Now()
c.Step(50 * time.Second)
PluginDuration.With(prometheus.Labels{"name": SchedulingName, "plugin": "fakePlugin1"}).Observe(metrics.SinceInSeconds(startTime))
PluginDuration.With(prometheus.Labels{
"name": SchedulingName,
"plugin_type": "filter",
"plugin_name": "fakePlugin1",
}).Observe(metrics.SinceInSeconds(startTime))
c.Step(30 * time.Second)
PluginDuration.With(prometheus.Labels{"name": SchedulingName, "plugin": "fakePlugin2"}).Observe(metrics.SinceInSeconds(startTime))
PluginDuration.With(prometheus.Labels{
"name": SchedulingName,
"plugin_type": "prioritizer",
"plugin_name": "fakePlugin2",
}).Observe(metrics.SinceInSeconds(startTime))

mfs, err := legacyregistry.DefaultGatherer.Gather()
if err != nil {
Expand Down
10 changes: 6 additions & 4 deletions pkg/placement/controllers/scheduling/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ func (s *pluginScheduler) Schedule(
filterResult, status := f.Filter(ctx, placement, filtered)

metrics.PluginDuration.With(prometheus.Labels{
"name": metrics.SchedulingName,
"plugin": f.Name(),
"name": metrics.SchedulingName,
"plugin_type": "filter",
"plugin_name": f.Name(),
}).Observe(s.handle.MetricsRecorder().SinceInSeconds(startTime))

filtered = filterResult.Filtered
Expand Down Expand Up @@ -250,8 +251,9 @@ func (s *pluginScheduler) Schedule(
scoreResult, status := p.Score(ctx, placement, filtered)

metrics.PluginDuration.With(prometheus.Labels{
"name": metrics.SchedulingName,
"plugin": p.Name(),
"name": metrics.SchedulingName,
"plugin_type": "prioritizer",
"plugin_name": p.Name(),
}).Observe(s.handle.MetricsRecorder().SinceInSeconds(startTime))

score := scoreResult.Scores
Expand Down

0 comments on commit 64bfc2b

Please sign in to comment.