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

Commit 692113e

Browse files
committed
Do not log gRPC NotFound and Canceled status code
- NotFound is returned, for example, when querying a Trace and the trace is not found. - Canceled when the context is canceled. Before we were checking the errors for context.Canceled but gRPC doesn't wrap the errors, it just creates an Status object that contains the error message.
1 parent 06ff2c6 commit 692113e

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ We use the following categories for changes:
2929
### Changed
3030
- Log throughput in the same line for samples, spans and metric metadata [#1643]
3131
- The `chunks_created` metrics was removed. [#1634]
32+
- Stop logging as an error grpc NotFound and Canceled status codes [#1645]
3233

3334
### Fixed
3435
- Do not collect telemetry if `timescaledb.telemetry_level=off` [#1612]

pkg/jaeger/store/store.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"context"
99
"time"
1010

11+
"github.com/pkg/errors"
1112
"github.com/prometheus/client_golang/prometheus"
1213

1314
"github.com/jaegertracing/jaeger/model"
@@ -76,9 +77,14 @@ func (p *Store) GetTrace(ctx context.Context, traceID model.TraceID) (*model.Tra
7677
metrics.QueryDuration.With(prometheus.Labels{"type": "trace", "handler": "Get_Trace", "code": code}).Observe(time.Since(start).Seconds())
7778
}()
7879
res, err := getTrace(ctx, p.builder, p.conn, traceID)
80+
7981
if err != nil {
80-
return nil, logError(err)
82+
if !errors.Is(err, spanstore.ErrTraceNotFound) {
83+
err = logError(err)
84+
}
85+
return nil, err
8186
}
87+
8288
code = "2xx"
8389
traceRequestsExec.Add(1)
8490
return res, nil

pkg/runner/runner.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ import (
2424
"go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp"
2525
"go.opentelemetry.io/otel"
2626
"google.golang.org/grpc"
27+
"google.golang.org/grpc/codes"
2728
"google.golang.org/grpc/credentials"
29+
"google.golang.org/grpc/status"
2830

2931
"github.com/google/uuid"
3032
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
@@ -67,9 +69,16 @@ func loggingUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.Un
6769

6870
func loggingStreamInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
6971
err := handler(srv, ss)
70-
if err != nil && !errors.Is(err, context.Canceled) {
71-
log.Error("msg", "error in GRPC call", "err", err)
72+
if err == nil {
73+
return nil
7274
}
75+
76+
st, ok := status.FromError(err)
77+
if ok && (st.Code() == codes.NotFound || st.Code() == codes.Canceled) {
78+
return err
79+
}
80+
81+
log.Error("msg", "error in GRPC call", "err", err)
7382
return err
7483
}
7584

0 commit comments

Comments
 (0)