Skip to content

Commit 206eb3e

Browse files
committed
test out non default buckets
1 parent f69e18f commit 206eb3e

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

go.mod

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ require (
9797
github.com/opencontainers/image-spec v1.1.1
9898
github.com/pkg/errors v0.9.1
9999
github.com/pquerna/otp v1.4.0
100-
github.com/prometheus/client_golang v1.20.5
101-
github.com/prometheus/common v0.60.1
102100
github.com/prometheus/client_golang v1.22.0
101+
github.com/prometheus/common v0.63.0
103102
github.com/quasoft/websspi v1.1.2
104103
github.com/redis/go-redis/v9 v9.7.3
105104
github.com/robfig/cron/v3 v3.0.1
@@ -221,12 +220,7 @@ require (
221220
github.com/josharian/intern v1.0.0 // indirect
222221
github.com/kevinburke/ssh_config v1.2.0 // indirect
223222
github.com/klauspost/pgzip v1.2.6 // indirect
224-
github.com/kr/pretty v0.3.1 // indirect
225-
github.com/kr/text v0.2.0 // indirect
226223
github.com/kylelemons/godebug v1.1.0 // indirect
227-
github.com/libdns/libdns v0.2.2 // indirect
228-
github.com/magiconair/properties v1.8.7 // indirect
229-
github.com/mailru/easyjson v0.7.7 // indirect
230224
github.com/libdns/libdns v1.0.0-beta.1 // indirect
231225
github.com/mailru/easyjson v0.9.0 // indirect
232226
github.com/markbates/going v1.0.3 // indirect
@@ -249,11 +243,7 @@ require (
249243
github.com/pierrec/lz4/v4 v4.1.22 // indirect
250244
github.com/pjbgf/sha1cd v0.3.2 // indirect
251245
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
252-
github.com/prometheus/client_model v0.6.1 // indirect
253-
github.com/prometheus/procfs v0.15.1 // indirect
254-
github.com/rhysd/actionlint v1.7.3 // indirect
255246
github.com/prometheus/client_model v0.6.2 // indirect
256-
github.com/prometheus/common v0.63.0 // indirect
257247
github.com/prometheus/procfs v0.16.1 // indirect
258248
github.com/rhysd/actionlint v1.7.7 // indirect
259249
github.com/rivo/uniseg v0.4.7 // indirect

routers/common/middleware.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ const (
2929
httpRequestMethod = "http_request_method"
3030
httpResponseStatusCode = "http_response_status_code"
3131
httpRoute = "http_route"
32+
kb = 1000
33+
mb = kb * kb
3234
)
3335

36+
// reference: https://opentelemetry.io/docs/specs/semconv/http/http-metrics/#http-server
3437
var (
38+
sizeBuckets = []float64{1 * kb, 2 * kb, 5 * kb, 10 * kb, 100 * kb, 500 * kb, 1 * mb, 2 * mb, 5 * mb, 10 * mb}
3539
// reqInflightGauge tracks the amount of currently handled requests
3640
reqInflightGauge = promauto.NewGaugeVec(prometheus.GaugeOpts{
3741
Namespace: "http",
@@ -43,22 +47,25 @@ var (
4347
reqDurationHistogram = promauto.NewHistogramVec(prometheus.HistogramOpts{
4448
Namespace: "http",
4549
Subsystem: "server",
46-
Name: "request_duration",
50+
Name: "request_duration_seconds", // diverge from spec to store the unit in metric.
4751
Help: "Measures the latency of HTTP requests processed by the server",
52+
Buckets: []float64{0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 30, 60, 120, 300}, // based on dotnet buckets https://github.com/open-telemetry/semantic-conventions/issues/336
4853
}, []string{httpRequestMethod, httpResponseStatusCode, httpRoute})
4954
// reqSizeHistogram tracks the size of request
5055
reqSizeHistogram = promauto.NewHistogramVec(prometheus.HistogramOpts{
5156
Namespace: "http",
5257
Subsystem: "server_request",
5358
Name: "body_size",
5459
Help: "Size of HTTP server request bodies.",
60+
Buckets: sizeBuckets,
5561
}, []string{httpRequestMethod, httpResponseStatusCode, httpRoute})
5662
// respSizeHistogram tracks the size of the response
5763
respSizeHistogram = promauto.NewHistogramVec(prometheus.HistogramOpts{
5864
Namespace: "http",
5965
Subsystem: "server_response",
6066
Name: "body_size",
6167
Help: "Size of HTTP server response bodies.",
68+
Buckets: sizeBuckets,
6269
}, []string{httpRequestMethod, httpResponseStatusCode, httpRoute})
6370
)
6471

0 commit comments

Comments
 (0)