From bfe9c7d008748058f60e08fdb04a2fb5e303bd62 Mon Sep 17 00:00:00 2001 From: Min Zeng Date: Tue, 14 Jan 2020 16:07:46 -0800 Subject: [PATCH] separate shortpoll and longpoll metrics --- server.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server.go b/server.go index c64dbd7..0ae9501 100644 --- a/server.go +++ b/server.go @@ -168,11 +168,15 @@ func (s *QProxyServer) AckMessages(ctx context.Context, in *rpc.AckMessagesReque func (s *QProxyServer) GetMessages(ctx context.Context, in *rpc.GetMessagesRequest) (resp *rpc.GetMessagesResponse, err error) { start := time.Now() - s.m.APIHits.WithLabelValues("GetMessages", in.QueueId.Namespace, in.QueueId.Name).Inc() + apiName := "GetMessages" + if in.LongPollSeconds <= 0 { + apiName = "GetMessagesShortPoll" + } + s.m.APIHits.WithLabelValues(apiName, in.QueueId.Namespace, in.QueueId.Name).Inc() defer func() { - s.m.APILatency.WithLabelValues("GetMessages", in.QueueId.Namespace, in.QueueId.Name).Observe(float64(time.Now().Sub(start))) + s.m.APILatency.WithLabelValues(apiName, in.QueueId.Namespace, in.QueueId.Name).Observe(float64(time.Now().Sub(start))) if err != nil { - s.m.APIErrors.WithLabelValues("GetMessages", in.QueueId.Namespace, in.QueueId.Name).Inc() + s.m.APIErrors.WithLabelValues(apiName, in.QueueId.Namespace, in.QueueId.Name).Inc() log.Println("Error GetMessages: ", err) } else { s.m.Received.WithLabelValues(in.QueueId.Namespace, in.QueueId.Name).Add(float64(len(resp.Messages)))