evanderkoogh / otel-cf-workers

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

'Fetcher is not defined' when accessing string environment variable in handler #57

Closed etinquis closed 1 year ago

etinquis commented 1 year ago

Repro at https://github.com/etinquis/cf-otel.

Run with docker-compose up -d --build. Hit the exposed port, result: image

Log:

[mf:err] ReferenceError: Fetcher is not defined
2023-09-16 11:56:13     at isFetcher (/app/node_modules/@microlabs/otel-cf-workers/src/instrumentation/env.ts:21:25)
2023-09-16 11:56:13     at Object.get (/app/node_modules/@microlabs/otel-cf-workers/src/instrumentation/env.ts:34:15)
2023-09-16 11:56:13     at proxyHandler.get (/app/node_modules/@microlabs/otel-cf-workers/src/wrap.ts:23:20)
2023-09-16 11:56:13     at fetch (/app/src/index.ts:36:27)
2023-09-16 11:56:13     at null.<anonymous> (/app/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:137:37)
2023-09-16 11:56:13     at AsyncLocalStorageContextManager.with (/app/node_modules/@microlabs/otel-cf-workers/src/context.ts:241:34)
2023-09-16 11:56:13     at ContextAPI2.with (/app/node_modules/@opentelemetry/api/src/api/context.ts:77:42)
2023-09-16 11:56:13     at WorkerTracer.startActiveSpan (/app/node_modules/@microlabs/otel-cf-workers/src/tracer.ts:93:22)
2023-09-16 11:56:13     at executeFetchHandler (/app/node_modules/@microlabs/otel-cf-workers/src/instrumentation/fetch.ts:135:25)
2023-09-16 11:56:13     at AsyncLocalStorageContextManager.with (/app/node_modules/@microlabs/otel-cf-workers/src/context.ts:241:34)
[mf:inf] GET /favicon.ico 500 Internal Server Error (36ms)

Expected (uncommenting https://github.com/etinquis/cf-otel/blob/b3c3d698ab6a858243730823f1d181ad011ca6f6/src/index.ts#L51C36-L51C36): image

etinquis commented 1 year ago

Can ResolveConfigFn support Promise returns? My tracing endpoint is authenticated, and I need to fetch a token occasionally.

mattfysh commented 1 year ago

hey @etinquis there's a small bug in rc.12 - can you downgrade to rc.10 or 11?

etinquis commented 1 year ago

Thanks; initial checks lead me to believe that rc.10 works and rc.11 doesn't.

evanderkoogh commented 1 year ago

Thanks for jumping in there with the suggestion @mattfysh!

And @etinquis, the problem should be fixed.. could you give it a go again?