Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Skip context.Canceled error in grpc logging interceptors
Browse files Browse the repository at this point in the history
context.Canceled is returned by grpc stream.Recv when you stop promscale with Ctrl-C.Skip logging the above error as the behavior is expected.

Signed-off-by: Arunprasad Rajkumar <ar.arunprasad@gmail.com>
  • Loading branch information
arajkumar committed Sep 5, 2022
1 parent 6f89768 commit ce43749
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package runner

import (
"context"
"errors"
"fmt"
"net"
"net/http"
Expand Down Expand Up @@ -57,15 +58,15 @@ func init() {

func loggingUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
m, err := handler(ctx, req)
if err != nil {
if err != nil && !errors.As(err, &context.Canceled) {
log.Error("msg", "error in GRPC call", "err", err)
}
return m, err
}

func loggingStreamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
err := handler(srv, ss)
if err != nil {
if err != nil && !errors.As(err, &context.Canceled) {
log.Error("msg", "error in GRPC call", "err", err)
}
return err
Expand Down

0 comments on commit ce43749

Please sign in to comment.