DataDog / datadog-lambda-js

The Datadog AWS Lambda Library for Node
Apache License 2.0
113 stars 35 forks source link

AWS Cloudformation Transform macro is adding two datadog layers , my deployment is running out due to codesize issue for lambda with these two layers #493

Closed irfanahmed24 closed 8 months ago

irfanahmed24 commented 8 months ago

AWS Cloudformation Transform macro is adding two datadog layers , my deployment is running out due to codesize issue for lambda with these two layers

irfanahmed24 commented 8 months ago

do we need both these layers for nodejs lambda , Please advise

arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Node18-x:96 arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Extension:47

astuyve commented 8 months ago

Hi, yes both layers are required for the default setup.

Although this library isn't the cloudformation macro project, the macro does seem to be working correctly here. One layer provides the tracing capability, the other is our Lambda Extension which ships logs, metrics, traces, profile data, and security signals back to datadog.

You can use the datadog lambda log forwarder instead of the datadog lambda extension if you'd rather. This can save about 30mb. More information is here.

If you're running out of space in due to dependencies, verify that you're not inadvertently packaging development-only dependencies into your application. You can inspect your node_modules directory and run something like du -hk | sort -n to see the list in size-order.

Finally if you're sure you need every dependency you are currently packagine, you may consider using container images instead of zip-based Lambda functions. This will increase the max from 250mb to a whopping 10gb, and substantially improve cold starts.

Hope that helps!

irfanahmed24 commented 8 months ago

Hi , Thank you for quick reply . we want to collect traces for our lambdas . My Lambda code size is around 30MB it says . Can you please tell me what is the size of those two layers .

arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Node18-x:96 arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Extension:47

Thanks irfan

astuyve commented 8 months ago

You can verify the layer sizes yourself following the documentation. Both layers combined are around 50mb now. If your code is only 30mb, that leaves 170mb unaccounted for.

I'd suggest downloading your function zip file itself from the AWS Lambda Console and inspecting it. You can do that with the export feature.

astuyve commented 8 months ago

Given that this library is not responsible for applying the lambda layers, and that the datadog-cloudformation-macro seems to be working normally, I'm going to close this issue.

If you're still running into size issues, the next best thing is to open a support ticket so we can inspect your function bundle itself. You can do so at support@datadoghq.com.

Thanks!