Skip to content

Commit 7397d02

Browse files
committed
Add middleware comments
1 parent 862df07 commit 7397d02

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

prometheus/promhttp/middleware.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ import (
3030
dto "github.com/prometheus/client_model/go"
3131
)
3232

33-
// ClientTrace adds middleware providing a histogram of outgoing request
34-
// latencies, partitioned by http client, request host and httptrace event.
33+
// ClientTrace accepts an ObserverVec interface and an httpClient, returning a
34+
// new httpClient that wraps the supplied httpClient. The provided ObserverVec
35+
// must be registered in a registry in order to be used. Note: Partitioning
36+
// histograms is expensive.
3537
func ClientTrace(obs prometheus.ObserverVec, next httpClient) httpClient {
36-
// The supplied histogram NEEDS a label for the httptrace event.
38+
// The supplied ObserverVec NEEDS a label for the httptrace events.
3739
// TODO: Using `event` for now, but any other name is acceptable.
3840

3941
checkEventLabel(obs)
@@ -83,8 +85,9 @@ func ClientTrace(obs prometheus.ObserverVec, next httpClient) httpClient {
8385
})
8486
}
8587

86-
// InFlight is middleware that instruments number of open requests partitioned
87-
// by http client and request host.
88+
// InFlightC accepts a Gauge and an httpClient, returning a new httpClient that
89+
// wraps the supplied httpClient. The provided Gauge must be registered in a
90+
// registry in order to be used.
8891
func InFlightC(gauge prometheus.Gauge, next httpClient) httpClient {
8992
return ClientMiddleware(func(r *http.Request) (*http.Response, error) {
9093
gauge.Inc()
@@ -97,6 +100,9 @@ func InFlightC(gauge prometheus.Gauge, next httpClient) httpClient {
97100
})
98101
}
99102

103+
// Counter accepts an CounterVec interface and an httpClient, returning a new
104+
// httpClient that wraps the supplied httpClient. The provided CounterVec
105+
// must be registered in a registry in order to be used.
100106
func CounterC(counter *prometheus.CounterVec, next httpClient) httpClient {
101107
code, method := checkLabels(counter)
102108

0 commit comments

Comments
 (0)