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

Change obsreport receiver calling pattern in awsxrayreceiver #3439

Merged
merged 1 commit into from
May 20, 2021
Merged
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
15 changes: 8 additions & 7 deletions receiver/awsxrayreceiver/internal/udppoller/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ type poller struct {

// all segments read by the poller will be sent to this channel
segChan chan RawSegment

obsrecv *obsreport.Receiver
}

// New creates a new UDP poller
Expand Down Expand Up @@ -113,6 +115,7 @@ func New(cfg *Config, logger *zap.Logger) (Poller, error) {
maxPollerCount: cfg.NumOfPollerToStart,
shutDown: make(chan struct{}),
segChan: make(chan RawSegment, segChanSize),
obsrecv: obsreport.NewReceiver(obsreport.ReceiverSettings{ReceiverID: cfg.ReceiverID, Transport: cfg.Transport}),
}, nil
}

Expand Down Expand Up @@ -168,10 +171,8 @@ func (p *poller) poll() {
case <-p.shutDown:
return
default:
ctx := obsreport.StartTraceDataReceiveOp(
ctx := p.obsrecv.StartTraceDataReceiveOp(
p.receiverLongLivedCtx,
p.receiverID,
Transport,
obsreport.WithLongLivedCtx())

bufPointer := &buffer
Expand All @@ -180,11 +181,11 @@ func (p *poller) poll() {
// TODO: We may want to attempt to shutdown/clean the broken socket and open a new one
// with the same address
p.logger.Error("Irrecoverable socket read error. Exiting poller", zap.Error(err))
obsreport.EndTraceDataReceiveOp(ctx, awsxray.TypeStr, 1, err)
p.obsrecv.EndTraceDataReceiveOp(ctx, awsxray.TypeStr, 1, err)
return
} else if errors.As(err, &errRecv) {
p.logger.Error("Recoverable socket read error", zap.Error(err))
obsreport.EndTraceDataReceiveOp(ctx, awsxray.TypeStr, 1, err)
p.obsrecv.EndTraceDataReceiveOp(ctx, awsxray.TypeStr, 1, err)
continue
}

Expand All @@ -196,7 +197,7 @@ func (p *poller) poll() {
if errors.As(err, &errRecv) {
p.logger.Error("Failed to split segment header and body",
zap.Error(err))
obsreport.EndTraceDataReceiveOp(ctx, awsxray.TypeStr, 1, err)
p.obsrecv.EndTraceDataReceiveOp(ctx, awsxray.TypeStr, 1, err)
continue
}

Expand All @@ -205,7 +206,7 @@ func (p *poller) poll() {
zap.String("header format", header.Format),
zap.Int("header version", header.Version),
)
obsreport.EndTraceDataReceiveOp(ctx, awsxray.TypeStr, 1,
p.obsrecv.EndTraceDataReceiveOp(ctx, awsxray.TypeStr, 1,
errors.New("dropped span due to missing body that contains segment"))
continue
}
Expand Down