Skip to content

Commit 3d980fe

Browse files
authored
Add gauge (#1304)
1 parent 6965c31 commit 3d980fe

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

backend/httpclient/datasource_metrics_middleware.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ var (
5252
}, []string{"datasource_type", "secure_socks_ds_proxy_enabled", "endpoint"},
5353
)
5454

55+
datasourceResponseGauge = promauto.NewGaugeVec(
56+
prometheus.GaugeOpts{
57+
Namespace: "plugins",
58+
Name: "datasource_response_size",
59+
Help: "gauge of data source response sizes returned to Grafana in bytes",
60+
}, []string{"datasource_type", "secure_socks_ds_proxy_enabled", "endpoint"},
61+
)
62+
5563
datasourceRequestsInFlight = promauto.NewGaugeVec(
5664
prometheus.GaugeOpts{
5765
Namespace: "plugins",
@@ -128,6 +136,7 @@ func executeMiddleware(next http.RoundTripper, datasourceType string, secureSock
128136
requestHistogram := datasourceRequestHistogram.MustCurryWith(labels)
129137
requestInFlight := datasourceRequestsInFlight.With(labels)
130138
responseSizeHistogram := datasourceResponseHistogram.With(labels)
139+
responseSizeGauge := datasourceResponseGauge.With(labels)
131140

132141
res, err := promhttp.InstrumentRoundTripperDuration(requestHistogram,
133142
promhttp.InstrumentRoundTripperCounter(requestCounter,
@@ -140,6 +149,7 @@ func executeMiddleware(next http.RoundTripper, datasourceType string, secureSock
140149
if res != nil && res.StatusCode != http.StatusSwitchingProtocols {
141150
res.Body = CountBytesReader(res.Body, func(bytesRead int64) {
142151
responseSizeHistogram.Observe(float64(bytesRead))
152+
responseSizeGauge.Set(float64(bytesRead))
143153
})
144154
}
145155

0 commit comments

Comments
 (0)