aws-otel-lambda
aws-otel-lambda copied to clipboard
Cannot redefine property: handler
Describe the bug
scope.addDefaultFunctionEnv({
[EnvVars.openTelemetryEnabled]: "true",
AWS_LAMBDA_EXEC_WRAPPER: "/opt/otel-handler",
})
const otelLayer = LayerVersion.fromLayerVersionArn(
this,
"OpenTelemetryLayer",
`arn:aws:lambda:${scope.region}:901920570463:layer:aws-otel-nodejs-amd64-ver-1-5-0:2`
)
scope.addDefaultFunctionLayers([otelLayer])
handler:
export const handler = async (): Promise<string> => {
...
}
❌ mish-platform-DbMigrations failed: Received response status [FAILED] from custom resource. Message returned: Cannot redefine property: handler
Logs: /aws/lambda/mish-platform-DbMigration-MigrationScriptMigration-hWdyvtv7f92D
at Function.defineProperty (<anonymous>)
at defineProperty (/opt/nodejs/node_modules/shimmer/index.js:14:10)
at AwsLambdaInstrumentation.wrap [as _wrap] (/opt/nodejs/node_modules/shimmer/index.js:56:3)
at InstrumentationNodeModuleFile.patch (/opt/nodejs/node_modules/@opentelemetry/instrumentation-aws-lambda/src/instrumentation.ts:124:20)
at AwsLambdaInstrumentation._onRequire (/opt/nodejs/node_modules/@opentelemetry/instrumentation-aws-lambda/node_modules/@opentelemetry/instrumentation/src/platform/node/instrumentation.ts:126:23)
at null.<anonymous> (/opt/nodejs/node_modules/@opentelemetry/instrumentation-aws-lambda/node_modules/@opentelemetry/instrumentation/src/platform/node/instrumentation.ts:161:25)
at Module.Hook._require.Module.require (/opt/nodejs/node_modules/require-in-the-middle/index.js:175:32)
at Module.Hook._require.Module.require (/opt/nodejs/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/opt/nodejs/node_modules/require-in-the-middle/index.js:101:39)
at Module.Hook._require.Module.require (/opt/nodejs/node_modules/require-in-the-middle/index.js:101:39) (RequestId: 582b69af-9ad1-4ffd-b0de-d8f9c32b24db)
Additional context Node 16, Serverless Stack
Can you please add more detail in the issue? Such as what is expected and what did you see instead.
I was hoping to instrument my application. I want to use https://www.prisma.io/docs/concepts/components/prisma-client/opentelemetry-tracing to gather data about what queries my serverless application is performing and have the results appear in xray.
This issue is stale because it has been open 90 days with no activity. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled
Still an issue for me
Tried it today, the issue is still there...
I think the root cause might be this CJS vs. ESM issue noted here
- https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1287
Using CJS vs ESM style exports fixed this issue for me.
E.g
export const handler = function() {}
refactored to
const handler = function() {}
module.exports = { handler }
This issue is stale because it has been open 90 days with no activity. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled
This issue was closed because it has been marked as stale for 30 days with no activity.