DataDog / datadog-lambda-js

The Datadog AWS Lambda Library for Node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

datadog: handler not initialized

naveen700 opened this issue · comments

Expected Behavior

Metric should have been sent to datadog in lambda instead getting error of handler not initialized.

#369

Actual Behavior

I am using sendDistributionMetric but while checking the lambda logs I am getting an error as datadog: handler not initialized.

Steps to Reproduce the Problem

  1. Using dd-trace and initializing it using init() method
  2. Then wrapping the handler in trace.
  3. And using method sendDistributionMetric to send the metric.

Specifications

  • Datadog Lambda Layer version: 7.96.0
  • dd trace: 5.6.0
  • Node version: Node 18.x

Stacktrace

2024-03-18T05:10:34.021Z 79214b2e-b340-469e-ac86-ec73b4e0ee51 ERROR [dd.trace_id=5898828417058474788 dd.span_id=1717120647592796076]
{
"status": "error",
"message": "datadog:handler not initialized"
}
@astuyve I have seen your comment and added the logs as sent and send metric as you mentioned in ticket #369
image

Hi @naveen700 - thanks for reaching out!

You shouldn't need to manually initialize DDtrace at all, this library handles that here. You also shouldn't need to manually wrap your handler, but without seeing that code it's hard to for me to help more.

This error (like the linked issue) is occurring because sendDistributionMetric is being called before the Datadog() method you'd use to wrap your handler. Typically this is because a user is attempting to send a metric during the initialization phase of the Lambda function.

We'll work towards buffering these metrics so this error doesn't occur, but if you're still having trouble I'd ask that you file a support ticket so that we can see your configuration and handler code and offer specific advice. You can attach this ticket to speed up the process.

Support can be reached at support@datadoghq.com, or using the Live Chat feature in the application.

Thanks!

Hi @astuyve,

Thanks for your prompt reply, we are able to solve this problem, with using node 20.x and while using datadog20 layer in lambda, we had issue with node 18 it was not able to create the lambda layer automatically with datadog. And another issue was that in the package.json of shared layer, it was suggested that not to put the dd-trace and datadog-lambda-js library and afiter removing it from package.json it solved the problem.

Okay, thanks for confirming!

I'll close this issue for now, feel free to re-open or follow up with any other issues!