We use Epsagon for tracing our serverless deployme...
# sst
r
We use Epsagon for tracing our serverless deployments and to do so we use a serverless framework plugin that automatically wraps each handler function when deploying. Is there an ‘official’ way to do something similar i.e. a plugin framework with SST?
We can get around it my manually wrapping each handler but I like the automated way that doesn’t rely on people remembering to do so
j
We don’t currently but I know @Frank has some ideas on how we can implement this.
r
Ok, cool, I’ll keep my eye out for developments 🙂
f
Yeah @Ross Coundon that’s a good point. I have seen Datadog has something along that line https://www.npmjs.com/package/datadog-cdk-constructs
So the code looks like:
Copy code
const datadog = new Datadog(this, "Datadog", ...);
datadog.addLambdaFunctions([a list of lambdas]);
The Datadog CDK construct takes in a list of lambda functions and installs the Datadog Lambda Library by attaching the Lambda Layers for Node.js and Python to your functions. It redirects to a replacement handler that initializes the Lambda Library without any required code changes.
Or alternatively, I’m thinking of letting ppl define
wrappers
like:
Copy code
new sst.Function(this, "MyFunction", {
  handler: "src/lambda.main",
  wrappers: [ epsagonWrapper ]
})
Where
easagonWrapper
can just be user defined wrapper function
r
That'd work
p
That'd be an alternative way of doing middleware then as well?
f
Yeah, and I’ve thought about adding default wrappers to functions for things most ppl probably need by default: like wrapping aws-sdk import with aws-xray-sdk; console.log full event and response when developing (ie. sst start); etc. And have a way for them to opt out.
p
Very nice!
f
Yeah.. I’ll need to get more feedback from u guys when i get to it 🙏
j
Wrappers would be cool. We actually have our own set of wrappers in an internal library to convert requests coming in and events from dynamodb hooks or sqs queues so it's all consistent and also to wrap it all with sentry for a catch all.
f
@justindra Yeah definitely a common use case.