Hey folks, Anyone used <datadog-lambda-js> with ss...
# help
a
Hey folks, Anyone used datadog-lambda-js with sst in development mode? It's throwing errors like this
Copy code
ERROR Error [TypeError]: (intermediate value)(intermediate value)(intermediate value).toLowerCase is not a function
    at TraceListener.onWrap (/code/messaging/node_modules/datadog-lambda-js/src/trace/listener.ts:117:67)
datadog-lambda-js
needs a wrapper around the function's handler and it seems like it's failing because sst is re-wrapping the handler. Is that assumption correct? If so, is there a way to have dd wrapper around sst wrapper? Thanks!
t
Hey Aram, I don't think SST wraps the handler. I'm using datadog I'll check how I have it setup
a
Hey @thdxr thanks for the reply. My code looks something like this
Copy code
import { datadog } from 'datadog-lambda-js';

async function myFunction() {
   ...
}

export const handler = datadog(myFunction);
t
Ah I'm not using
datadog-lambda-js
I'm using thier CDK construct
Copy code
const datadog = new Datadog(this, "Datadog", {
      nodeLayerVersion: 59,
      extensionLayerVersion: 9,
      apiKey: "...",
    })
    datadog.addLambdaFunctions([router])
I found this to work better
a
oh, nice, so I can pass functions as array items here and remove the wrappers, hmm
let me give it a try
a
Thanks @thdxr , that seems to be working fine. A question though, how are you resolving the dd api key so that it doesn't come as a plain text in CI or anywhere else?
t
You can put it in an environment variable or in SSM and resolve it in cdk
The datadog API key is exposed in public when using it with a frontend so it's not considered that sensitive