@@ -22,8 +22,6 @@ import (
2222 "net/http"
2323
2424 "github.com/go-logr/logr"
25- "github.com/prometheus/client_golang/prometheus"
26- "github.com/prometheus/client_golang/prometheus/promhttp"
2725 jsonpatch "gomodules.xyz/jsonpatch/v2"
2826 admissionv1 "k8s.io/api/admission/v1"
2927 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -209,27 +207,6 @@ func (w *Webhook) InjectFunc(f inject.Func) error {
209207 return setFields (w .Handler )
210208}
211209
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-
233210// StandaloneOptions let you configure a StandaloneWebhook.
234211type StandaloneOptions struct {
235212 // 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
265242 if opts .Path == "" {
266243 return hook , nil
267244 }
268- return InstrumentedHook (opts .Path , hook ), nil
245+ return metrics . InstrumentedHook (opts .Path , hook ), nil
269246}
0 commit comments