From e548c916ba02af3ab935793064a0536fd073659c Mon Sep 17 00:00:00 2001 From: Min Zeng Date: Fri, 3 Jan 2020 12:09:36 -0800 Subject: [PATCH] log errors --- server.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server.go b/server.go index 42d3111..c64dbd7 100644 --- a/server.go +++ b/server.go @@ -3,6 +3,7 @@ package qproxy import ( "context" "fmt" + "log" "time" "github.com/wish/qproxy/backends/sqs" @@ -69,6 +70,7 @@ func (s *QProxyServer) ListQueues(in *rpc.ListQueuesRequest, stream rpc.QProxy_L s.m.APILatency.WithLabelValues("ListQueues", in.Namespace, "").Observe(float64(time.Now().Sub(start))) if err != nil { s.m.APIErrors.WithLabelValues("ListQueues", in.Namespace, "").Inc() + log.Println("Error ListQueues: ", err) } }() streamWithTimeout := ListQueuesServerStream{ @@ -85,6 +87,7 @@ func (s *QProxyServer) GetQueue(ctx context.Context, in *rpc.GetQueueRequest) (r s.m.APILatency.WithLabelValues("GetQueue", in.Id.Namespace, in.Id.Name).Observe(float64(time.Now().Sub(start))) if err != nil { s.m.APIErrors.WithLabelValues("GetQueue", in.Id.Namespace, in.Id.Name).Inc() + log.Println("Error GetQueue: ", err) } }() ctx = s.setContextTimeout(ctx, in.RPCTimeout) @@ -98,6 +101,7 @@ func (s *QProxyServer) CreateQueue(ctx context.Context, in *rpc.CreateQueueReque s.m.APILatency.WithLabelValues("CreateQueue", in.Id.Namespace, in.Id.Name).Observe(float64(time.Now().Sub(start))) if err != nil { s.m.APIErrors.WithLabelValues("CreateQueue", in.Id.Namespace, in.Id.Name).Inc() + log.Println("Error CreateQueue: ", err) } }() ctx = s.setContextTimeout(ctx, in.RPCTimeout) @@ -111,6 +115,7 @@ func (s *QProxyServer) DeleteQueue(ctx context.Context, in *rpc.DeleteQueueReque s.m.APILatency.WithLabelValues("DeleteQueue", in.Id.Namespace, in.Id.Name).Observe(float64(time.Now().Sub(start))) if err != nil { s.m.APIErrors.WithLabelValues("DeleteQueue", in.Id.Namespace, in.Id.Name).Inc() + log.Println("Error DeleteQueue: ", err) } }() ctx = s.setContextTimeout(ctx, in.RPCTimeout) @@ -124,6 +129,7 @@ func (s *QProxyServer) ModifyQueue(ctx context.Context, in *rpc.ModifyQueueReque s.m.APILatency.WithLabelValues("ModifyQueue", in.Id.Namespace, in.Id.Name).Observe(float64(time.Now().Sub(start))) if err != nil { s.m.APIErrors.WithLabelValues("ModifyQueue", in.Id.Namespace, in.Id.Name).Inc() + log.Println("Error ModifyQueue: ", err) } }() ctx = s.setContextTimeout(ctx, in.RPCTimeout) @@ -137,6 +143,7 @@ func (s *QProxyServer) PurgeQueue(ctx context.Context, in *rpc.PurgeQueueRequest s.m.APILatency.WithLabelValues("PurgeQueue", in.Id.Namespace, in.Id.Name).Observe(float64(time.Now().Sub(start))) if err != nil { s.m.APIErrors.WithLabelValues("PurgeQueue", in.Id.Namespace, in.Id.Name).Inc() + log.Println("Error PurgeQueue: ", err) } }() ctx = s.setContextTimeout(ctx, in.RPCTimeout) @@ -150,6 +157,7 @@ func (s *QProxyServer) AckMessages(ctx context.Context, in *rpc.AckMessagesReque s.m.APILatency.WithLabelValues("AckMessages", in.QueueId.Namespace, in.QueueId.Name).Observe(float64(time.Now().Sub(start))) if err != nil { s.m.APIErrors.WithLabelValues("AckMessages", in.QueueId.Namespace, in.QueueId.Name).Inc() + log.Println("Error AckMessages: ", err) } else { s.m.Acknowledged.WithLabelValues(in.QueueId.Namespace, in.QueueId.Name).Add(float64(len(in.Receipts) - len(resp.Failed))) } @@ -165,6 +173,7 @@ func (s *QProxyServer) GetMessages(ctx context.Context, in *rpc.GetMessagesReque s.m.APILatency.WithLabelValues("GetMessages", 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() + log.Println("Error GetMessages: ", err) } else { s.m.Received.WithLabelValues(in.QueueId.Namespace, in.QueueId.Name).Add(float64(len(resp.Messages))) } @@ -180,6 +189,7 @@ func (s *QProxyServer) PublishMessages(ctx context.Context, in *rpc.PublishMessa s.m.APILatency.WithLabelValues("PublishMessages", in.QueueId.Namespace, in.QueueId.Name).Observe(float64(time.Now().Sub(start))) if err != nil { s.m.APIErrors.WithLabelValues("PublishMessages", in.QueueId.Namespace, in.QueueId.Name).Inc() + log.Println("Error PublishMessages: ", err) } else { s.m.Published.WithLabelValues(in.QueueId.Namespace, in.QueueId.Name).Add(float64(len(in.Messages) - len(resp.Failed))) } @@ -195,6 +205,7 @@ func (s *QProxyServer) ModifyAckDeadline(ctx context.Context, in *rpc.ModifyAckD s.m.APILatency.WithLabelValues("ModifyAckDeadline", in.QueueId.Namespace, in.QueueId.Name).Observe(float64(time.Now().Sub(start))) if err != nil { s.m.APIErrors.WithLabelValues("ModifyAckDeadline", in.QueueId.Namespace, in.QueueId.Name).Inc() + log.Println("Error ModifyAckDeadline: ", err) } }() ctx = s.setContextTimeout(ctx, in.RPCTimeout) @@ -208,6 +219,7 @@ func (s *QProxyServer) Healthcheck(ctx context.Context, in *rpc.HealthcheckReque s.m.APILatency.WithLabelValues("Healthcheck", "", "").Observe(float64(time.Now().Sub(start))) if err != nil { s.m.APIErrors.WithLabelValues("Healthcheck", "", "").Inc() + log.Println("Error Healthcheck: ", err) } }() return s.backend.Healthcheck(ctx, in)