Skip to content

Commit 9df3149

Browse files
authored
Define busy error type in processor and return related error in gRPC handler (#2314)
Signed-off-by: Pavol Loffay <[email protected]>
1 parent 5ad8e0a commit 9df3149

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Diff for: cmd/collector/app/handler/grpc_handler.go

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818
"context"
1919

2020
"go.uber.org/zap"
21+
"google.golang.org/grpc/codes"
22+
"google.golang.org/grpc/status"
2123

2224
"github.com/jaegertracing/jaeger/cmd/collector/app/processor"
2325
"github.com/jaegertracing/jaeger/proto-gen/api_v2"
@@ -49,6 +51,9 @@ func (g *GRPCHandler) PostSpans(ctx context.Context, r *api_v2.PostSpansRequest)
4951
SpanFormat: processor.ProtoSpanFormat,
5052
})
5153
if err != nil {
54+
if err == processor.ErrBusy {
55+
return nil, status.Errorf(codes.ResourceExhausted, err.Error())
56+
}
5257
g.logger.Error("cannot process spans", zap.Error(err))
5358
return nil, err
5459
}

Diff for: cmd/collector/app/processor/interface.go

+4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@
1515
package processor
1616

1717
import (
18+
"errors"
1819
"io"
1920

2021
"github.com/jaegertracing/jaeger/model"
2122
)
2223

24+
// ErrBusy signalizes that processor cannot process incoming data
25+
var ErrBusy = errors.New("server busy")
26+
2327
// SpansOptions additional options passed to processor along with the spans.
2428
type SpansOptions struct {
2529
SpanFormat SpanFormat

Diff for: cmd/collector/app/span_processor.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package app
1717

1818
import (
19-
"fmt"
2019
"sync"
2120
"time"
2221

@@ -164,7 +163,7 @@ func (sp *spanProcessor) ProcessSpans(mSpans []*model.Span, options processor.Sp
164163
for i, mSpan := range mSpans {
165164
ok := sp.enqueueSpan(mSpan, options.SpanFormat, options.InboundTransport)
166165
if !ok && sp.reportBusy {
167-
return nil, fmt.Errorf("server busy")
166+
return nil, processor.ErrBusy
168167
}
169168
retMe[i] = ok
170169
}

0 commit comments

Comments
 (0)