Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define busy error type in processor #2314

Merged
merged 2 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/collector/app/handler/grpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"context"

"go.uber.org/zap"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/jaegertracing/jaeger/cmd/collector/app/processor"
"github.com/jaegertracing/jaeger/proto-gen/api_v2"
Expand Down Expand Up @@ -49,6 +51,9 @@ func (g *GRPCHandler) PostSpans(ctx context.Context, r *api_v2.PostSpansRequest)
SpanFormat: processor.ProtoSpanFormat,
})
if err != nil {
if err == processor.ErrBusy {
return nil, status.Errorf(codes.ResourceExhausted, err.Error())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurishkuro it wasn't clear to me what error should we use here https://grpc.io/docs/guides/error/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think GRPC_STATUS_RESOURCE_EXHAUSTED

}
g.logger.Error("cannot process spans", zap.Error(err))
return nil, err
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/collector/app/processor/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
package processor

import (
"errors"
"io"

"github.com/jaegertracing/jaeger/model"
)

// ErrBusy signalizes that processor cannot process incoming data
var ErrBusy = errors.New("server busy")

// SpansOptions additional options passed to processor along with the spans.
type SpansOptions struct {
SpanFormat SpanFormat
Expand Down
3 changes: 1 addition & 2 deletions cmd/collector/app/span_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package app

import (
"fmt"
"sync"
"time"

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