I'm trying to add Epsagon as a layer as per the in...
# sst
r
I'm trying to add Epsagon as a layer as per the instructions here. My code looks like this:
Copy code
if (!scope.local) {
      console.log(`Adding epsagon layer from ${process.env.EPSAGON_LAYER_ARN}`);
      const epsagon = LayerVersion.fromLayerVersionArn(this, 'EpsagonLayer', process.env.EPSAGON_LAYER_ARN);
      scope.addDefaultFunctionLayers([epsagon]);
      scope.addDefaultFunctionEnv({
        EPSAGON_TOKEN: process.env.EPSAGON_TOKEN,
        EPSAGON_APP_NAME: process.env.EPSAGON_APP_NAME,
        NODE_OPTIONS: '-r epsagon-frameworks --enable-source-maps',
      });
    }
It's deployed via seed and I see the console.log inside the if block with the correct layer ARN but no layer is added to any of the functions. What could be going on?
t
Is this line at the beginning of the app file before you added stacks?
Oh nevermind this is inside a stack
r
No, it's inside the stack.
t
Is this stack initialized before other stacks?
r
Was just about to try it in the index.ts before stack creation
This is the only stack
t
Ah there may be a bug with using app.setDefault not effecting the current stack functions
I'll look into this today
Workaround is using this.setDefault
r
Ok, I'll try that. Moving to index.ts gives the error
Copy code
Error: Import at 'EpsagonLayer' should be created in the scope of a Stack, but no Stack found
t
Yeah would have to use the callback version of the function
r
got ya
Using this. worked, thanks
a
@Ross Coundon did you get tracing to work?
r
About to find out!
a
Ok let me know your findings please 🙂
r
Will do
Not looking hopeful
Epsagon seems to have removed Live Chat and links to help from the website and they've killed our joint Slack workspace. Cisco...
Looks like it's email only now 😞
What I might do, as a stop gap, is export a wrapped version for deployment and an unwrapped version for testing
a
😞
How you do the wrapping thing? from lambda code?
r
Yeah
So where I export a function like this
Copy code
export const handleGetAllUsers: APIGatewayProxyHandler = async () => {}
I will also export a wrapped version that SST uses like this
Copy code
const wrappedHandleGetAllUsers = epsagon.lambdaWrapper(handleGetAllUsers);

export { wrappedHandleGetAllUsers };
a
Yeah makes sense.
r
I've emailed Epsagon's support address to report the issue too
I'll keep you posted...
a
I did and they said to use wrapper.
Which is crap.
Why layer exists if it’s not doing anything?
Did the wrapper enable auto tracing automatically?
r
Yeah, that's the way we've always done it up until now
or via the auto-wrapping plugin in SLS framework
a
Yes, auto wrapping too.
I want that.
Let’s build a wrapper in SST (?).
r
Yeah, that would be nice
a
Let’s do it 🙂
r
Hello Epsagon Customer,  Now that the acquisition is closed and Epsagon is officially part of Cisco, our engineering resources have shifted to focus on building a new Cisco product.  Consequently, we are no longer supporting customers via their Slack channels.  For any support questions, please correspond with us via email at support@epsagon.com.  Thanks for your understanding. They didn't bcc the distribution list 🤦🏻‍♂️
Latest in the saga. Epsagon have said that the epsagon-frameworks library doesn't work with nodejs. Which is odd when the docs say this:
a
😐
W T F !!!
r
Yeah, this is a bug in the docs, rather than the code...
a
So the only way is using the wrapper in the lambda code?
r
Seems so.