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

Function newInstrument

middleware/instrument_test.go:89–129  ·  middleware/instrument_test.go::newInstrument
(registry *prometheus.Registry)

Source from the content-addressed store, hash-verified

87}
88
89func newInstrument(registry *prometheus.Registry) Instrument {
90 reg := promauto.With(registry)
91
92 const throughputUnit = "unit"
93 const LatencyCutoff = 100 * time.Millisecond
94
95 return Instrument{
96 Duration: reg.NewHistogramVec(prometheus.HistogramOpts{
97 Name: "request_duration_seconds",
98 Help: "Time (in seconds) spent serving HTTP requests.",
99 Buckets: instrument.DefBuckets,
100 }, []string{"method", "route", "status_code", "ws"}),
101 PerTenantDuration: reg.NewHistogramVec(prometheus.HistogramOpts{
102 Name: "per_tenant_request_duration_seconds",
103 Help: "Time (in seconds) spent serving HTTP requests for a particular tenant.",
104 Buckets: instrument.DefBuckets,
105 }, []string{"method", "route", "status_code", "ws", "tenant"}),
106 RequestBodySize: reg.NewHistogramVec(prometheus.HistogramOpts{
107 Name: "request_message_bytes",
108 Help: "Size (in bytes) of messages received in the request.",
109 Buckets: BodySizeBuckets,
110 }, []string{"method", "route"}),
111 ResponseBodySize: reg.NewHistogramVec(prometheus.HistogramOpts{
112 Name: "response_message_bytes",
113 Help: "Size (in bytes) of messages sent in response.",
114 Buckets: BodySizeBuckets,
115 }, []string{"method", "route"}),
116 InflightRequests: reg.NewGaugeVec(prometheus.GaugeOpts{
117 Name: "inflight_requests",
118 Help: "Current number of inflight requests.",
119 }, []string{"method", "route"}),
120 LatencyCutoff: LatencyCutoff,
121 ThroughputUnit: throughputUnit,
122 RequestThroughput: reg.NewHistogramVec(prometheus.HistogramOpts{
123 Name: "request_throughput_" + throughputUnit,
124 Help: "Server throughput running requests.",
125 ConstLabels: prometheus.Labels{"cutoff_ms": strconv.FormatInt(LatencyCutoff.Milliseconds(), 10)},
126 Buckets: []float64{1, 5, 10},
127 }, []string{"method", "route"}),
128 }
129}
130
131func TestExtractValueFromMultiValueHeader(t *testing.T) {
132 tests := []struct {

Callers 1

Calls 1

WithMethod · 0.80

Tested by

no test coverage detected