From 3e94f9eeb7ba35822cc4bf663f3a8f30c3e3bcda Mon Sep 17 00:00:00 2001 From: gurke Date: Fri, 27 Sep 2024 08:03:52 +0200 Subject: [PATCH] fix(lambda): changed memory warning when using the lambda extension (#1344) --- packages/aws-lambda/src/wrapper.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/aws-lambda/src/wrapper.js b/packages/aws-lambda/src/wrapper.js index bbd159d8a8..048bd3e1bc 100644 --- a/packages/aws-lambda/src/wrapper.js +++ b/packages/aws-lambda/src/wrapper.js @@ -345,13 +345,28 @@ function shouldUseLambdaExtension() { return false; } if (memorySize < 256) { - logger.debug( + let logFn = logger.debug; + + // CASE: We try to determine if the customer has the extension installed. We need to put a warning + // because the extension is **not** working and might block the lambda extension when + // its not used correctly e.g. slow startup of extension or waiting for invokes or incoming spans + // from the tracer. + if (process.env._HANDLER?.includes('instana-aws-lambda-auto-wrap')) { + logFn = logger.warn; + } + + logFn( 'The Lambda function is configured with less than 256 MB of memory according to the value of ' + - `AWS_LAMBDA_FUNCTION_MEMORY_SIZE: ${memorySetting}. Offloading data via a Lambda extension does currently ` + - 'not work reliably with low memory settings, therefore not using the Lambda extension.' + `AWS_LAMBDA_FUNCTION_MEMORY_SIZE: ${memorySetting}. The Lambda extension does ` + + 'not work with 256mb reliably with low memory settings. ' + + 'As the extension is already running, it might ' + + 'block the lambda execution which can result in larger execution times. Please configure at least ' + + '256 MB of memory for your Lambda function.' ); + return false; } + return true; } }