| 1 | package caddyscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/ |
| 2 | |
| 3 | import ( |
| 4 | "net/httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/" |
| 5 | |
| 6 | "github.com/prometheus/client_golang/prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/" |
| 7 | |
| 8 | "github.com/caddyserver/caddy/v2/internal/metricsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/internal/metrics`/" |
| 9 | ) |
| 10 | |
| 11 | // define and register the metrics used in this package. |
| 12 | func initscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/init().() { |
| 13 | const ns, sub = "caddy", "admin" |
| 14 | adminMetricsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/adminMetrics..requestCountscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/adminMetrics:requestCount. = prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.NewCounterVecscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/NewCounterVec().(prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.CounterOptsscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterOpts#{ |
| 15 | Namespacescip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterOpts#Namespace.: ns, |
| 16 | Subsystemscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterOpts#Subsystem.: sub, |
| 17 | Namescip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterOpts#Name.: "http_requests_total", |
| 18 | Helpscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterOpts#Help.: "Counter of requests made to the Admin API's HTTP endpoints.", |
| 19 | }, []string{"handler", "path", "code", "method"}) |
| 20 | adminMetricsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/adminMetrics..requestErrorsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/adminMetrics:requestErrors. = prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.NewCounterVecscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/NewCounterVec().(prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.CounterOptsscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterOpts#{ |
| 21 | Namespacescip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterOpts#Namespace.: ns, |
| 22 | Subsystemscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterOpts#Subsystem.: sub, |
| 23 | Namescip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterOpts#Name.: "http_request_errors_total", |
| 24 | Helpscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterOpts#Help.: "Number of requests resulting in middleware errors.", |
| 25 | }, []string{"handler", "path", "method"}) |
| 26 | globalMetricsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/globalMetrics..configSuccessscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/globalMetrics:configSuccess. = prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.NewGaugescip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/NewGauge().(prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.GaugeOptsscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/GaugeOpts#{ |
| 27 | Namescip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterOpts#Name.: "caddy_config_last_reload_successful", |
| 28 | Helpscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterOpts#Help.: "Whether the last configuration reload attempt was successful.", |
| 29 | }) |
| 30 | globalMetricsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/globalMetrics..configSuccessTimescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/globalMetrics:configSuccessTime. = prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.NewGaugescip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/NewGauge().(prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.GaugeOptsscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/GaugeOpts#{ |
| 31 | Namescip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterOpts#Name.: "caddy_config_last_reload_success_timestamp_seconds", |
| 32 | Helpscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterOpts#Help.: "Timestamp of the last successful configuration reload.", |
| 33 | }) |
| 34 | } |
| 35 | |
| 36 | // adminMetrics is a collection of metrics that can be tracked for the admin API. |
| 37 | var adminMetricsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/adminMetrics. = struct { |
| 38 | requestCountscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/adminMetrics:requestCount. *prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.CounterVecscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterVec# |
| 39 | requestErrorsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/adminMetrics:requestErrors. *prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.CounterVecscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterVec# |
| 40 | }{} |
| 41 | |
| 42 | // globalMetrics is a collection of metrics that can be tracked for Caddy global state |
| 43 | var globalMetricsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/globalMetrics. = struct { |
| 44 | configSuccessscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/globalMetrics:configSuccess. prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.Gaugescip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/Gauge# |
| 45 | configSuccessTimescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/globalMetrics:configSuccessTime. prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.Gaugescip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/Gauge# |
| 46 | }{} |
| 47 | |
| 48 | // Similar to promhttp.InstrumentHandlerCounter, but upper-cases method names |
| 49 | // instead of lower-casing them. |
| 50 | // |
| 51 | // Unlike promhttp.InstrumentHandlerCounter, this assumes a "code" and "method" |
| 52 | // label is present, and will panic otherwise. |
| 53 | func instrumentHandlerCounterscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/instrumentHandlerCounter().(counter *prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.CounterVecscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterVec#, next httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.Handlerscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Handler#) httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.HandlerFuncscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/HandlerFunc# { |
| 54 | return httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.HandlerFuncscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/HandlerFunc#(func(w httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/ResponseWriter#, r *httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.Requestscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#) { |
| 55 | d := newDelegatorscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/newDelegator().(w) |
| 56 | next.ServeHTTPscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Handler#ServeHTTP().(d, r) |
| 57 | counter.Withscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/CounterVec#With().(prometheusscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/.Labelsscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/Labels#{ |
| 58 | "code": metricsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/internal/metrics`/.SanitizeCodescip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/internal/metrics`/SanitizeCode().(d.statusscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/delegator#status.), |
| 59 | "method": metricsscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/internal/metrics`/.SanitizeMethodscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2/internal/metrics`/SanitizeMethod().(r.Methodscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/Request#Method.), |
| 60 | }).Incscip-go gomod github.com/prometheus/client_golang v1.23.2 `github.com/prometheus/client_golang/prometheus`/Counter#Inc().() |
| 61 | }) |
| 62 | } |
| 63 | |
| 64 | func newDelegatorscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/newDelegator().(w httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/ResponseWriter#) *delegatorscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/delegator# { |
| 65 | return &delegatorscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/delegator#{ |
| 66 | ResponseWriterscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/delegator#ResponseWriter.: w, |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | type delegatorscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/delegator# struct { |
| 71 | httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.ResponseWriterscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/delegator#ResponseWriter. |
| 72 | statusscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/delegator#status. int |
| 73 | } |
| 74 | |
| 75 | func (d *delegatorscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/delegator#) WriteHeaderscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/delegator#WriteHeader().(code int) { |
| 76 | d.statusscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/delegator#status. = code |
| 77 | d.ResponseWriterscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/delegator#ResponseWriter..WriteHeaderscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/ResponseWriter#WriteHeader().(code) |
| 78 | } |
| 79 | |
| 80 | // Unwrap returns the underlying ResponseWriter, necessary for |
| 81 | // http.ResponseController to work correctly. |
| 82 | func (d *delegatorscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/delegator#) Unwrapscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/delegator#Unwrap().() httpscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/.ResponseWriterscip-go gomod github.com/golang/go/src go1.25.1 `net/http`/ResponseWriter# { |
| 83 | return d.ResponseWriterscip-go gomod github.com/caddyserver/caddy/v2 . `github.com/caddyserver/caddy/v2`/delegator#ResponseWriter. |
| 84 | } |