Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit 6e4b1ba

Browse files
committed
reqs with 0 series: fix metrics and msgp responses
In practice this case rarely/never happens because graphite will first do a metrics find, and only if there's stuff to find, will it call render. But I verified by calling MT directly that it works.
1 parent 2981674 commit 6e4b1ba

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

api/graphite.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,19 @@ func (s *Server) renderMetrics(ctx *middleware.Context, request models.GraphiteR
267267
}
268268
}
269269

270+
reqRenderSeriesCount.Value(len(reqs))
271+
reqRenderTargetCount.Value(len(request.Targets))
272+
270273
if len(reqs) == 0 {
271-
response.Write(ctx, response.NewJson(200, []string{}, ""))
274+
if request.Format == "msgp" {
275+
var series models.SeriesByTarget
276+
response.Write(ctx, response.NewMsgp(200, series))
277+
} else {
278+
response.Write(ctx, response.NewJson(200, []string{}, ""))
279+
}
272280
return
273281
}
274282

275-
reqRenderSeriesCount.Value(len(reqs))
276-
reqRenderTargetCount.Value(len(request.Targets))
277283
if (toUnix - fromUnix) >= logMinDur {
278284
log.Info("HTTP Render: INCOMING REQ %q from: %q, to: %q target cnt: %d, maxDataPoints: %d",
279285
ctx.Req.Method, from, to, len(request.Targets), request.MaxDataPoints)

0 commit comments

Comments
 (0)