Skip to content

Commit

Permalink
log errors
Browse files Browse the repository at this point in the history
  • Loading branch information
zengmin-wish committed Jan 6, 2020
1 parent 001b5d0 commit e548c91
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package qproxy
import (
"context"
"fmt"
"log"
"time"

"github.com/wish/qproxy/backends/sqs"
Expand Down Expand Up @@ -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{
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)))
}
Expand All @@ -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)))
}
Expand All @@ -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)))
}
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit e548c91

Please sign in to comment.