appsignal / opentelemetry-instrumentation-bullmq

OTel Auto-instrumentation for BullMQ
Apache License 2.0
4 stars 3 forks source link

Instrumentation cannot find package.json on startup #7

Open maxdeichmann opened 3 months ago

maxdeichmann commented 3 months ago

I am using this package in a dockerized Nextjs application. When i try to run the application, i get the error below. Is this something you encountered already?

Context:

web:dev: Error: An error occurred while loading instrumentation hook: Cannot find module '/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/web/package.json'
web:dev:     at webpackEmptyContext (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/web/.next/server/_instrument_node_modules_pnpm_appsignal_opentelemetry-instrumentation-bullmq_0_7_1_bullmq_5_4-44d1a0.js:20:10)
web:dev:     at eval (webpack-internal:///(instrument)/../node_modules/.pnpm/@appsignal+opentelemetry-instrumentation-bullmq@0.7.1_bullmq@5.4.3/node_modules/@appsignal/opentelemetry-instrumentation-bullmq/dist/version.js:11:222)
web:dev:     at (instrument)/../node_modules/.pnpm/@appsignal+opentelemetry-instrumentation-bullmq@0.7.1_bullmq@5.4.3/node_modules/@appsignal/opentelemetry-instrumentation-bullmq/dist/version.js (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/web/.next/server/vendor-chunks/@appsignal+opentelemetry-instrumentation-bullmq@0.7.1_bullmq@5.4.3.js:42:1)
web:dev:     at __webpack_require__ (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/web/.next/server/webpack-runtime.js:33:43)
web:dev:     at eval (webpack-internal:///(instrument)/../node_modules/.pnpm/@appsignal+opentelemetry-instrumentation-bullmq@0.7.1_bullmq@5.4.3/node_modules/@appsignal/opentelemetry-instrumentation-bullmq/dist/instrumentation.js:22:19)
web:dev:     at (instrument)/../node_modules/.pnpm/@appsignal+opentelemetry-instrumentation-bullmq@0.7.1_bullmq@5.4.3/node_modules/@appsignal/opentelemetry-instrumentation-bullmq/dist/instrumentation.js (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/web/.next/server/vendor-chunks/@appsignal+opentelemetry-instrumentation-bullmq@0.7.1_bullmq@5.4.3.js:52:1)
web:dev:     at __webpack_require__ (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/web/.next/server/webpack-runtime.js:33:43)
web:dev:     at eval (webpack-internal:///(instrument)/../node_modules/.pnpm/@appsignal+opentelemetry-instrumentation-bullmq@0.7.1_bullmq@5.4.3/node_modules/@appsignal/opentelemetry-instrumentation-bullmq/dist/index.js:4:25)
web:dev:     at (instrument)/../node_modules/.pnpm/@appsignal+opentelemetry-instrumentation-bullmq@0.7.1_bullmq@5.4.3/node_modules/@appsignal/opentelemetry-instrumentation-bullmq/dist/index.js (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/web/.next/server/vendor-chunks/@appsignal+opentelemetry-instrumentation-bullmq@0.7.1_bullmq@5.4.3.js:31:1)
web:dev:     at __webpack_require__ (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/web/.next/server/webpack-runtime.js:33:43)
web:dev:     at eval (webpack-internal:///(instrument)/./src/datadog.server.config.ts:14:105)
web:dev:     at (instrument)/./src/datadog.server.config.ts (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/web/.next/server/_instrument_node_modules_pnpm_appsignal_opentelemetry-instrumentation-bullmq_0_7_1_bullmq_5_4-44d1a0.js:142:1)
web:dev:     at Function.__webpack_require__ (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/web/.next/server/webpack-runtime.js:33:43)
web:dev:     at async Module.register (webpack-internal:///(instrument)/./src/instrumentation.ts:15:9)
web:dev:     at async DevServer.runInstrumentationHookIfAvailable (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/node_modules/.pnpm/next@14.2.3_@babel+core@7.24.3_@opentelemetry+api@1.8.0_@playwright+test@1.43.1_babel-plugin-_onhpcaxa43qd7mh36cjg7s3u5i/node_modules/next/dist/server/dev/next-dev-server.js:437:17)
web:dev:     at async Span.traceAsyncFn (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/node_modules/.pnpm/next@14.2.3_@babel+core@7.24.3_@opentelemetry+api@1.8.0_@playwright+test@1.43.1_babel-plugin-_onhpcaxa43qd7mh36cjg7s3u5i/node_modules/next/dist/trace/trace.js:154:20)
web:dev:     at async DevServer.prepareImpl (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/node_modules/.pnpm/next@14.2.3_@babel+core@7.24.3_@opentelemetry+api@1.8.0_@playwright+test@1.43.1_babel-plugin-_onhpcaxa43qd7mh36cjg7s3u5i/node_modules/next/dist/server/dev/next-dev-server.js:214:9)
web:dev:     at async NextServer.prepare (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/node_modules/.pnpm/next@14.2.3_@babel+core@7.24.3_@opentelemetry+api@1.8.0_@playwright+test@1.43.1_babel-plugin-_onhpcaxa43qd7mh36cjg7s3u5i/node_modules/next/dist/server/next.js:161:13)
web:dev:     at async initializeImpl (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/node_modules/.pnpm/next@14.2.3_@babel+core@7.24.3_@opentelemetry+api@1.8.0_@playwright+test@1.43.1_babel-plugin-_onhpcaxa43qd7mh36cjg7s3u5i/node_modules/next/dist/server/lib/render-server.js:98:5)
web:dev:     at async initialize (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/node_modules/.pnpm/next@14.2.3_@babel+core@7.24.3_@opentelemetry+api@1.8.0_@playwright+test@1.43.1_babel-plugin-_onhpcaxa43qd7mh36cjg7s3u5i/node_modules/next/dist/server/lib/router-server.js:423:22)
web:dev:     at async Server.<anonymous> (/Users/maximiliandeichmann/development/github.com/langfuse/langfuse/node_modules/.pnpm/next@14.2.3_@babel+core@7.24.3_@opentelemetry+api@1.8.0_@playwright+test@1.43.1_babel-plugin-_onhpcaxa43qd7mh36cjg7s3u5i/node_modules/next/dist/server/lib/start-server.js:249:36) {
web:dev:   code: 'MODULE_NOT_FOUND'
web:dev: }
unflxw commented 1 month ago

Hi @maxdeichmann @Steffen911,

Thank you for reporting this issue, and apologies for the delay in getting back to you.

Could you provide a repository with a sample application that reproduces the issue? That would be, for example, a freshly initialized Next.js application that uses this instrumentation with a standard OpenTelemetry setup.

Could you also try adding @appsignal/opentelemetry-instrumentation-bullmq to the serverExternalPackages Next.js configuration option? This seems like it could be an issue with Webpack bundling.

Steffen911 commented 1 month ago

@unflxw Thank you for the response. I just tested your suggestion and can confirm that the initialization succeeds if I include the bullmq instrumentation in serverComponentsExternalPackages.

unflxw commented 1 month ago

Interesting, thank you for reporting back @Steffen911. I'm unsure why that would be necessary, but nonetheless it's good to know there's a workaround.