MCPcopy
hub / github.com/grafana/dskit / newBenchStatsHandler

Function newBenchStatsHandler

middleware/grpc_stats_bench_test.go:13–32  ·  middleware/grpc_stats_bench_test.go::newBenchStatsHandler

newBenchStatsHandler builds a handler with real Prometheus vecs (same as prod).

(b *testing.B)

Source from the content-addressed store, hash-verified

11
12// newBenchStatsHandler builds a handler with real Prometheus vecs (same as prod).
13func newBenchStatsHandler(b *testing.B) stats.Handler {
14 b.Helper()
15 reg := prometheus.NewRegistry()
16
17 received := promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{
18 Name: "bench_received_payload_bytes",
19 Buckets: BodySizeBuckets,
20 }, []string{"method", "route"})
21
22 sent := promauto.With(reg).NewHistogramVec(prometheus.HistogramOpts{
23 Name: "bench_sent_payload_bytes",
24 Buckets: BodySizeBuckets,
25 }, []string{"method", "route"})
26
27 inflight := promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{
28 Name: "bench_inflight_requests",
29 }, []string{"method", "route"})
30
31 return NewStatsHandler(reg, received, sent, inflight, false)
32}
33
34// BenchmarkHandleRPC_InPayload measures the per-message hot path for incoming
35// payloads on a streaming RPC (the dominant case in QueryStream).

Calls 3

NewStatsHandlerFunction · 0.85
HelperMethod · 0.80
WithMethod · 0.80

Tested by

no test coverage detected