Skip to content

Commit 0b91487

Browse files
authored
feat(httpclient): Updated metrics base name (#167)
1 parent 67034e5 commit 0b91487

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

httpclient/transport/metrics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
)
1111

1212
const (
13-
HttpClientMetricsRequestsCount = "httpclient_requests_total"
14-
HttpClientMetricsRequestsDuration = "httpclient_requests_duration_seconds"
13+
HttpClientMetricsRequestsCount = "http_client_requests_total"
14+
HttpClientMetricsRequestsDuration = "http_client_requests_duration_seconds"
1515
)
1616

1717
// MetricsTransport is a wrapper around [http.RoundTripper] with some [MetricsTransportConfig] configuration.

httpclient/transport/metrics_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ func TestMetricsTransportRoundTrip(t *testing.T) {
3939
// requests counter assertions
4040
expectedCounterMetric := fmt.Sprintf(
4141
`
42-
# HELP httpclient_requests_total Number of performed HTTP requests
43-
# TYPE httpclient_requests_total counter
44-
httpclient_requests_total{host="%s",method="GET",path="",status="5xx"} 1
42+
# HELP http_client_requests_total Number of performed HTTP requests
43+
# TYPE http_client_requests_total counter
44+
http_client_requests_total{host="%s",method="GET",path="",status="5xx"} 1
4545
`,
4646
server.URL,
4747
)
4848

4949
err = testutil.GatherAndCompare(
5050
prometheus.DefaultGatherer,
5151
strings.NewReader(expectedCounterMetric),
52-
"httpclient_requests_total",
52+
"http_client_requests_total",
5353
)
5454
assert.NoError(t, err)
5555
}
@@ -107,11 +107,11 @@ func TestMetricsTransportRoundTripWithBaseAndConfig(t *testing.T) {
107107
// requests counter assertions
108108
expectedCounterMetric := fmt.Sprintf(
109109
`
110-
# HELP foo_bar_httpclient_requests_total Number of performed HTTP requests
111-
# TYPE foo_bar_httpclient_requests_total counter
112-
foo_bar_httpclient_requests_total{host="%s",method="GET",path="",status="204"} 1
113-
foo_bar_httpclient_requests_total{host="%s",method="GET",path="/foo/4/baz",status="204"} 1
114-
foo_bar_httpclient_requests_total{host="%s",method="GET",path="/foo/{fooId}/bar?page={pageId}",status="204"} 3
110+
# HELP foo_bar_http_client_requests_total Number of performed HTTP requests
111+
# TYPE foo_bar_http_client_requests_total counter
112+
foo_bar_http_client_requests_total{host="%s",method="GET",path="",status="204"} 1
113+
foo_bar_http_client_requests_total{host="%s",method="GET",path="/foo/4/baz",status="204"} 1
114+
foo_bar_http_client_requests_total{host="%s",method="GET",path="/foo/{fooId}/bar?page={pageId}",status="204"} 3
115115
`,
116116
server.URL,
117117
server.URL,
@@ -121,7 +121,7 @@ func TestMetricsTransportRoundTripWithBaseAndConfig(t *testing.T) {
121121
err := testutil.GatherAndCompare(
122122
registry,
123123
strings.NewReader(expectedCounterMetric),
124-
"foo_bar_httpclient_requests_total",
124+
"foo_bar_http_client_requests_total",
125125
)
126126
assert.NoError(t, err)
127127
}
@@ -161,17 +161,17 @@ func TestMetricsTransportRoundTripWithFailure(t *testing.T) {
161161
// requests counter assertions
162162
expectedCounterMetric := fmt.Sprintf(
163163
`
164-
# HELP foo_bar_httpclient_requests_total Number of performed HTTP requests
165-
# TYPE foo_bar_httpclient_requests_total counter
166-
foo_bar_httpclient_requests_total{host="%s",method="GET",path="",status="error"} 1
164+
# HELP foo_bar_http_client_requests_total Number of performed HTTP requests
165+
# TYPE foo_bar_http_client_requests_total counter
166+
foo_bar_http_client_requests_total{host="%s",method="GET",path="",status="error"} 1
167167
`,
168168
server.URL,
169169
)
170170

171171
err = testutil.GatherAndCompare(
172172
registry,
173173
strings.NewReader(expectedCounterMetric),
174-
"foo_bar_httpclient_requests_total",
174+
"foo_bar_http_client_requests_total",
175175
)
176176
assert.NoError(t, err)
177177
}

0 commit comments

Comments
 (0)