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

Lambda missing log: log didn't send to datadog if execution is fast #16

Open
mary2501 opened this issue Sep 2, 2024 · 2 comments
Open

Comments

@mary2501
Copy link

mary2501 commented Sep 2, 2024

Hi folks,
I found this error: I have a valid configuration for Datadog; when I send the datadog's log, if the lambda execution is too fast, this log will not be sent.
I tried using the same configuration and adding a sleep instruction, and the log was sent correctly.

Would anyone be able to help me find a solution?
I also tried without success:

  • Send the flush instructions after each log
  • to set the option sendImmediate: true on the option transport
  • to set sendIntervalMs: 1 on the option transport
@mary2501
Copy link
Author

mary2501 commented Sep 2, 2024

Additional information: if I use the datadog library on the CDK, which adds a lambda layer (https://docs.datadoghq.com/serverless/libraries_integrations/cdk/), I don't have this problem.

@theogravity
Copy link
Owner

theogravity commented Sep 26, 2024

My guess since the issue is that your lambda ends quickly is because the logs are sent in an async fashion outside the normal execution flow:

https://github.com/theogravity/datadog-transports/blob/main/packages/datadog-transport-common/src/DataDogTransport.ts#L59

So if you have something like pino.info("test") and your lambda ends quickly, there is always that chance that the logs don't get sent out because the log send is sent out-of-band, so the async call to send the log may or may not resolve.

but overall, if you're using pino for this it's prob not a good idea because pino is async out-of-band by design

for your issue to be resolved, src/DataDogTransport.ts would have to be refactored to add the ability to await on the send, and you'd have to use a logging library that is not pino (or create your own) that you can await on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants