Closed brunopenso closed 1 year ago
Some updates:
serverless-plugin-log-retention
plugins:
- serverless-prune-plugin
- serverless-plugin-lambda-insights
- serverless-domain-manager
- serverless-offline
- serverless-newrelic-lambda-layers
The error continue :(
@brunopenso I see that you're including newrelic
in your deployment package (as dependencies). That's the source of your trouble: you're installing that in your /var/task/node_modules
...but since you're using the Lambda Layer (via this plugin), there's another agent that's also installed at /opt/nodejs/node_modules
.
I'd assume that you've included New Relic explicitly because you're recording custom attributes, or doing something else that requires newrelic
explicitly. What you can do is move it to devDependencies
so that your function can use the locally-installed agent, without it being deployed also alongside your function. Then you can continue to use the layer-installed agent for instrumentation.
(NewRelicHeader
is defined in the New Relic Node Agent, so if you have two dependencies attempting to define it, that suggests a duplicate agent. The proof of this is that you have an explicit dependency on the agent in addition to using the layer.)
HI @mrickard, thanks for the answer.
In the end the problem were related to the enricher + winston dependencies.
For the future users that arrive here:
You don't need to use newrelic and newrelic/enricher with lambda, because the layer is already doing the job for you :)
Hello everyone,
I'm trying to run a lambda in AWS using this layer and I'm getting this error:
Duplicate middleware name 'NewRelicHeader'
I'm trying to get the stacktrace but no success yet because of internal policies I don't have write access to cloud watch logs and all of our logs are sent to NewRelic, and there isn't any logs in NewRelic.
I'm using node 16 with serverless v3.
Here is my package.json(simplified):
Here is the serverless.yml (simplified):