Skip to content

Commit 1763b69

Browse files
committed
fixup: replace sync.Once with nil check
Signed-off-by: Florian Lehner <[email protected]>
1 parent bd59d4a commit 1763b69

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

apmproxy/apmserver.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"math"
2929
"math/rand"
3030
"net/http"
31-
"sync"
3231
"time"
3332

3433
"github.com/elastic/apm-aws-lambda/accumulator"
@@ -53,7 +52,6 @@ func (c *Client) ForwardApmData(ctx context.Context) error {
5352
c.logger.Warn("Failed to start APM data forwarder due to client unhealthy")
5453
return nil
5554
}
56-
var once sync.Once
5755
var lambdaDataChan chan []byte
5856
for {
5957
select {
@@ -68,11 +66,12 @@ func (c *Client) ForwardApmData(ctx context.Context) error {
6866
if err := c.forwardAgentData(ctx, data); err != nil {
6967
return err
7068
}
71-
once.Do(func() {
69+
if lambdaDataChan == nil {
7270
// With the first successful request to c.forwardAgent Data() metadata should be
7371
// available and processing data from c.LambdaDataChannel can start.
7472
lambdaDataChan = c.LambdaDataChannel
75-
})
73+
c.logger.Debug("Assigned Lambda data channel")
74+
}
7675
case data := <-lambdaDataChan:
7776
if err := c.forwardLambdaData(ctx, data); err != nil {
7877
return err

0 commit comments

Comments
 (0)