From 8bb714eb62eeb2321e955ad1b0753eb69fc9717e Mon Sep 17 00:00:00 2001 From: Huy Vo Date: Thu, 20 May 2021 16:37:59 -0400 Subject: [PATCH] Make changes to awsxrayreceiver (#3439) --- .../awsxrayreceiver/internal/udppoller/poller.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/receiver/awsxrayreceiver/internal/udppoller/poller.go b/receiver/awsxrayreceiver/internal/udppoller/poller.go index 4db2870be472..f379c49fd18c 100644 --- a/receiver/awsxrayreceiver/internal/udppoller/poller.go +++ b/receiver/awsxrayreceiver/internal/udppoller/poller.go @@ -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 @@ -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 } @@ -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 @@ -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 } @@ -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 } @@ -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 }