Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only flush logs if logs collection is enabled #510

Merged
merged 4 commits into from
Jul 25, 2024

Conversation

kruskall
Copy link
Member

If logs collection is disabled or logs subscription failed then logsClient is nil

@github-actions github-actions bot added the aws-λ-extension AWS Lambda Extension label Jul 25, 2024
@rockdaboot
Copy link
Contributor

LGTM, but can you also add a test for when there is no log collection?

@@ -96,8 +96,10 @@ func (app *App) Run(ctx context.Context) error {
backgroundDataSendWg.Wait()
if event.EventType == extension.Shutdown {
app.logger.Infof("Exiting due to shutdown event with reason %s", event.ShutdownReason)
// Flush buffered logs if any
app.logsClient.FlushData(ctx, event.RequestID, event.InvokedFunctionArn, app.apmClient.LambdaDataChannel, true)
if app.logsClient != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, check lc for nil in FlushData and return early (slightly reduces number of lines changed).

kruskall added 3 commits July 25, 2024 13:39
There is no coverage/test for the app when logs collection is disabled
Add a testcase to ensure standard events chain work even if logs
collection is disabled.
@kruskall kruskall merged commit b307ea4 into elastic:main Jul 25, 2024
10 checks passed
@kruskall kruskall deleted the fix/nil-pointer-logs branch July 25, 2024 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws-λ-extension AWS Lambda Extension
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants