Skip to content

Commit

Permalink
Make changes to awsxrayreceiver (#3439)
Browse files Browse the repository at this point in the history
  • Loading branch information
humivo authored May 20, 2021
1 parent b10cfd7 commit 8bb714e
Showing 1 changed file with 8 additions and 7 deletions.
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

0 comments on commit 8bb714e

Please sign in to comment.