@@ -22,8 +22,6 @@ import (
22
22
"net/http"
23
23
24
24
"github.com/go-logr/logr"
25
- "github.com/prometheus/client_golang/prometheus"
26
- "github.com/prometheus/client_golang/prometheus/promhttp"
27
25
jsonpatch "gomodules.xyz/jsonpatch/v2"
28
26
admissionv1 "k8s.io/api/admission/v1"
29
27
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -209,27 +207,6 @@ func (w *Webhook) InjectFunc(f inject.Func) error {
209
207
return setFields (w .Handler )
210
208
}
211
209
212
- // InstrumentedHook adds some instrumentation on top of the given webhook.
213
- func InstrumentedHook (path string , hookRaw http.Handler ) http.Handler {
214
- lbl := prometheus.Labels {"webhook" : path }
215
-
216
- lat := metrics .RequestLatency .MustCurryWith (lbl )
217
- cnt := metrics .RequestTotal .MustCurryWith (lbl )
218
- gge := metrics .RequestInFlight .With (lbl )
219
-
220
- // Initialize the most likely HTTP status codes.
221
- cnt .WithLabelValues ("200" )
222
- cnt .WithLabelValues ("500" )
223
-
224
- return promhttp .InstrumentHandlerDuration (
225
- lat ,
226
- promhttp .InstrumentHandlerCounter (
227
- cnt ,
228
- promhttp .InstrumentHandlerInFlight (gge , hookRaw ),
229
- ),
230
- )
231
- }
232
-
233
210
// StandaloneOptions let you configure a StandaloneWebhook.
234
211
type StandaloneOptions struct {
235
212
// Scheme is the scheme used to resolve runtime.Objects to GroupVersionKinds / Resources
@@ -265,5 +242,5 @@ func StandaloneWebhook(hook *Webhook, opts StandaloneOptions) (http.Handler, err
265
242
if opts .Path == "" {
266
243
return hook , nil
267
244
}
268
- return InstrumentedHook (opts .Path , hook ), nil
245
+ return metrics . InstrumentedHook (opts .Path , hook ), nil
269
246
}
0 commit comments