|
| 1 | +/* |
| 2 | +Copyright 2023 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package metrics |
| 18 | + |
| 19 | +import ( |
| 20 | + "sync" |
| 21 | + |
| 22 | + "k8s.io/component-base/metrics" |
| 23 | + "k8s.io/component-base/metrics/legacyregistry" |
| 24 | +) |
| 25 | + |
| 26 | +const taintEvictionControllerSubsystem = "taint_eviction_controller" |
| 27 | + |
| 28 | +var ( |
| 29 | + // PodDeletionsTotal counts the number of Pods deleted by TaintEvictionController since its start. |
| 30 | + PodDeletionsTotal = metrics.NewCounter( |
| 31 | + &metrics.CounterOpts{ |
| 32 | + Subsystem: taintEvictionControllerSubsystem, |
| 33 | + Name: "pod_deletions_total", |
| 34 | + Help: "Total number of Pods deleted by TaintEvictionController since its start.", |
| 35 | + StabilityLevel: metrics.ALPHA, |
| 36 | + }, |
| 37 | + ) |
| 38 | + |
| 39 | + // PodDeletionsLatency tracks the latency, in seconds, between the time when a taint effect has been activated |
| 40 | + // for the Pod and its deletion. |
| 41 | + PodDeletionsLatency = metrics.NewHistogram( |
| 42 | + &metrics.HistogramOpts{ |
| 43 | + Subsystem: taintEvictionControllerSubsystem, |
| 44 | + Name: "pod_deletion_duration_seconds", |
| 45 | + Help: "Latency, in seconds, between the time when a taint effect has been activated for the Pod and its deletion via TaintEvictionController.", |
| 46 | + Buckets: []float64{0.005, 0.025, 0.1, 0.5, 1, 2.5, 10, 30, 60, 120, 180, 240}, // 5ms to 4m |
| 47 | + StabilityLevel: metrics.ALPHA, |
| 48 | + }, |
| 49 | + ) |
| 50 | +) |
| 51 | + |
| 52 | +var registerMetrics sync.Once |
| 53 | + |
| 54 | +// Register registers TaintEvictionController metrics. |
| 55 | +func Register() { |
| 56 | + registerMetrics.Do(func() { |
| 57 | + legacyregistry.MustRegister(PodDeletionsTotal) |
| 58 | + legacyregistry.MustRegister(PodDeletionsLatency) |
| 59 | + }) |
| 60 | +} |
0 commit comments