See the metrics. hello metric will be recorded 10, but hello_from_queue is less than 10 (even 0 or 1).
This is the minimal repro.
Actually, I am using https://github.com/vendia/serverless-express in a "CALLBACK" resolution mode.
I want to submit a DD metrics even after Lambda callback is executed.
Expected Behavior
A metric
hello_from_queue
is sent.Actual Behavior
A metric
hello_from_queue
is not sent for most of invocations. Instead, error los are written in a CloudWatch log stream:Steps to Reproduce the Problem
1. Create a Node.js 18.x Lambda with the attached code
```javascript "use strict"; const { sendDistributionMetric } = require("datadog-lambda-js"); const queue = []; exports.handler = (event, context, callback) => { context.callbackWaitsForEmptyEventLoop = false; // This metric succeeds, but... sendDistributionMetric("hello", 1); queue.push(new Promise((resolve, reject) => { setTimeout(() => { try { // This metric rarely succeeds sendDistributionMetric("hello_from_queue", 1); resolve("ok"); } catch (e) { reject(e); } }, 100 * Math.random()); })); callback(null, { statusCode: 200, body: JSON.stringify({ message: "Hello from Lambda!", }), }); }; ```hello
metric will be recorded10
, buthello_from_queue
is less than10
(even0
or1
).This is the minimal repro. Actually, I am using https://github.com/vendia/serverless-express in a "CALLBACK" resolution mode. I want to submit a DD metrics even after Lambda callback is executed.
Specifications
Stacktrace
N/A