Skip to content

Commit

Permalink
Merge pull request #10 from logzio/aws-dev
Browse files Browse the repository at this point in the history
v1.0.1 - flush buffered logs if exists, before the function run ends
  • Loading branch information
yotamloe authored Jan 3, 2023
2 parents 271e7cc + b5753aa commit 4419b91
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func initLogger(ctx context.Context, request events.APIGatewayProxyRequest) zap.
firehoseRequestId := request.Headers["X-Amz-Firehose-Request-Id"]
config := zap.NewProductionConfig()
config.EncoderConfig.StacktraceKey = "" // to hide stacktrace info
config.OutputPaths = []string{"stdout"} // write to stdout
config.InitialFields = map[string]interface{}{
"aws_account": account,
"lambda_invocation_id": awsRequestId,
Expand Down Expand Up @@ -250,6 +251,8 @@ func summaryValuesToMetrics(metricsToSendSlice pdata.InstrumentationLibraryMetri
}
func HandleRequest(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
log := initLogger(ctx, request)
// flush buffered logs if exists, before the function run ends
defer log.Sync()
metricCount := 0
dataPointCount := 0
shippingErrors := new(ErrorCollector)
Expand Down

0 comments on commit 4419b91

Please sign in to comment.