Code refactoring for bpa operator
[icn.git] / cmd / bpa-operator / vendor / sigs.k8s.io / controller-runtime / pkg / webhook / internal / metrics / metrics.go
1 /*
2 Copyright 2018 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         "github.com/prometheus/client_golang/prometheus"
21
22         "sigs.k8s.io/controller-runtime/pkg/metrics"
23 )
24
25 var (
26         // TotalRequests is a prometheus metric which counts the total number of requests that
27         // the webhook server has received.
28         TotalRequests = prometheus.NewCounterVec(
29                 prometheus.CounterOpts{
30                         Name: "controller_runtime_webhook_requests_total",
31                         Help: "Total number of admission requests",
32                 },
33                 []string{"webhook", "succeeded"},
34         )
35
36         // RequestLatency is a prometheus metric which is a histogram of the latency
37         // of processing admission requests.
38         RequestLatency = prometheus.NewHistogramVec(
39                 prometheus.HistogramOpts{
40                         Name: "controller_runtime_webhook_latency_seconds",
41                         Help: "Histogram of the latency of processing admission requests",
42                 },
43                 []string{"webhook"},
44         )
45 )
46
47 func init() {
48         metrics.Registry.MustRegister(
49                 TotalRequests,
50                 RequestLatency)
51 }