Skip to content

Commit 4419b91

Browse files
authored
Merge pull request #10 from logzio/aws-dev
v1.0.1 - flush buffered logs if exists, before the function run ends
2 parents 271e7cc + b5753aa commit 4419b91

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

handler/handler.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ func initLogger(ctx context.Context, request events.APIGatewayProxyRequest) zap.
101101
firehoseRequestId := request.Headers["X-Amz-Firehose-Request-Id"]
102102
config := zap.NewProductionConfig()
103103
config.EncoderConfig.StacktraceKey = "" // to hide stacktrace info
104+
config.OutputPaths = []string{"stdout"} // write to stdout
104105
config.InitialFields = map[string]interface{}{
105106
"aws_account": account,
106107
"lambda_invocation_id": awsRequestId,
@@ -250,6 +251,8 @@ func summaryValuesToMetrics(metricsToSendSlice pdata.InstrumentationLibraryMetri
250251
}
251252
func HandleRequest(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
252253
log := initLogger(ctx, request)
254+
// flush buffered logs if exists, before the function run ends
255+
defer log.Sync()
253256
metricCount := 0
254257
dataPointCount := 0
255258
shippingErrors := new(ErrorCollector)

0 commit comments

Comments
 (0)