Skip to content

Commit fb06834

Browse files
authored
Update naming for initializing collectors and tweak some comments. (#1968)
1 parent b1d6a1d commit fb06834

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

internal/servers/worker/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (w *Worker) handler(props HandlerProperties) (http.Handler, error) {
4242
mux.Handle("/v1/proxy", h)
4343

4444
genericWrappedHandler := w.wrapGenericHandler(mux, props)
45-
metricHandler := metric.InstrumentProxyHttpHandler(genericWrappedHandler)
45+
metricHandler := metric.InstrumentHttpHandler(genericWrappedHandler)
4646
return metricHandler, nil
4747
}
4848

internal/servers/worker/internal/metric/proxy_http.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ const (
2525
)
2626

2727
// httpTimeUntilHeader collects measurements of how long it takes
28-
// the boundary system to hijack an HTTP request into a websocket connection
29-
// for the proxy worker.
28+
// the boundary worker to write back the first header to the requester.
3029
var httpTimeUntilHeader prometheus.ObserverVec = prometheus.NewHistogramVec(
3130
prometheus.HistogramOpts{
3231
Namespace: globals.MetricNamespace,
@@ -61,10 +60,10 @@ func pathLabel(incomingPath string) string {
6160
return invalidPathValue
6261
}
6362

64-
// InstrumentProxyHttpHandler provides a proxy handler which measures
65-
// time until header is returned form the server and attaches status code,
66-
// method, and path labels for each of these measurements.
67-
func InstrumentProxyHttpHandler(wrapped http.Handler) http.Handler {
63+
// InstrumentHttpHandler provides a handler which measures time until header
64+
// is written by the server and attaches status code, method, and path
65+
// labels for the relevant measurements.
66+
func InstrumentHttpHandler(wrapped http.Handler) http.Handler {
6867
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
6968
l := prometheus.Labels{
7069
labelHttpPath: pathLabel(req.URL.Path),
@@ -76,10 +75,10 @@ func InstrumentProxyHttpHandler(wrapped http.Handler) http.Handler {
7675
})
7776
}
7877

79-
// InstrumentProxyHttpCollectors registers the proxy collectors to the default
80-
// prometheus register and initializes them to 0 for all possible label
78+
// InitializeHttpCollectors registers the proxy collectors to the provided
79+
// prometheus register and initializes them to 0 for the most likely label
8180
// combinations.
82-
func InstrumentProxyHttpCollectors(r prometheus.Registerer) {
81+
func InitializeHttpCollectors(r prometheus.Registerer) {
8382
if r == nil {
8483
return
8584
}

internal/servers/worker/worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ type Worker struct {
6666
}
6767

6868
func New(conf *Config) (*Worker, error) {
69-
metric.InstrumentProxyHttpCollectors(conf.PrometheusRegisterer)
69+
metric.InitializeHttpCollectors(conf.PrometheusRegisterer)
7070
w := &Worker{
7171
conf: conf,
7272
logger: conf.Logger.Named("worker"),

0 commit comments

Comments
 (0)