evanderkoogh / otel-cf-workers

An OpenTelemetry compatible library for instrumenting and exporting traces for Cloudflare Workers
BSD 3-Clause "New" or "Revised" License
249 stars 51 forks source link

Setup with "@cloudflare/vitest-pool-workers"? #173

Open tsteckenborn opened 1 month ago

tsteckenborn commented 1 month ago

Hey there,

has someone a working setup in conjunction with "@cloudflare/vitest-pool-workers"?

I'm currently running in different issues, such as:

Failed to load url @opentelemetry/sdk-trace-base (resolved id: @opentelemetry/sdk-trace-base)

and / or:

No such module "Users/.../node_modules/.pnpm/@opentelemetry+resources@1.26.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/os".
  imported from "Users/.../node_modules/.pnpm/@opentelemetry+resources@1.26.0_@opentelemetry+api@1.9.0/node_modules/@opentelemetry/resources/build/esm/detectors/platform/node/HostDetectorSync.js"

I'd assume for now that it's due to some configurations on my end. If somebody has a working sample together with the vitest pool workers it would save me some time and I'd be grateful :)

jahands commented 1 month ago

I believe this issue is related to https://github.com/cloudflare/workers-sdk/issues/6581

evanderkoogh commented 1 month ago

Yeah.. that certainly seems like a similar issue indeed. And not sure if there is anything I could do to fix that in this library.

If the issue is only in @opentelemetry/sdk-trace-base and not in @opentelemetry/api, or if you do not do any manual instrumentation, you should be able to test the handler without the instrument calls.

jahands commented 1 month ago

Came up with a workaround: https://github.com/cloudflare/workers-sdk/issues/6581#issuecomment-2383594102