File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import (
2929 "math/rand"
3030 "net/http"
3131 "time"
32+ "sync"
3233
3334 "github.com/elastic/apm-aws-lambda/accumulator"
3435 "github.com/elastic/apm-aws-lambda/version"
@@ -52,6 +53,7 @@ func (c *Client) ForwardApmData(ctx context.Context) error {
5253 c .logger .Warn ("Failed to start APM data forwarder due to client unhealthy" )
5354 return nil
5455 }
56+ var once sync.Once
5557 var lambdaDataChan chan []byte
5658 for {
5759 select {
@@ -66,9 +68,11 @@ func (c *Client) ForwardApmData(ctx context.Context) error {
6668 }
6769 return err
6870 }
69- // Wait for metadata to be available, metadata will be available as soon as
70- // the first agent data is processed.
71- lambdaDataChan = c .LambdaDataChannel
71+ once .Do (func () {
72+ // Wait for metadata to be available, metadata will be available as soon as
73+ // the first agent data is processed.
74+ lambdaDataChan = c .LambdaDataChannel
75+ })
7276 case data := <- lambdaDataChan :
7377 if err := c .forwardLambdaData (ctx , data ); err != nil {
7478 return err
You can’t perform that action at this time.
0 commit comments