@heystack/otel 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/workers.d.ts +16 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -157,6 +157,8 @@ As belt-and-suspenders the exporter also drops any span whose HTTP target points
|
|
|
157
157
|
|
|
158
158
|
## Migration / versioning
|
|
159
159
|
|
|
160
|
+
- **`0.3.4`** — **type-inference fix (Workers).** Restores `instrument()`'s ability to infer the handler's concrete `Env` type. In 0.3.3 the signature was `instrument<E = unknown, H extends WorkerHandler<E>>`, so `E` defaulted to `unknown` and was never recovered from the handler — under `strictFunctionTypes` a Worker typed `fetch(req, env: Env, ctx)` then failed to compile (`TS2345: 'Env' is not assignable to 'unknown'`) unless the caller passed `instrument<Env>(...)` explicitly. 0.3.4 infers `E` from the handler argument (`instrument<H extends WorkerHandler<any>>(...): Instrumented<EnvOf<H>, H>`), so a bare `instrument(handler, cfg)` type-checks again. Runtime behaviour is unchanged; no `0.3.3` consumer needs the explicit type arg after upgrading.
|
|
161
|
+
- **`0.3.3`** — `/next` uses bare, exports-mapped dynamic imports so the OpenNext (Cloudflare Pages) build resolves the workers entry correctly (fixes a build break). Workers/Node paths unchanged.
|
|
160
162
|
- **`0.3.2`** — runtime-correctness fixes:
|
|
161
163
|
- **ContextManager registered (CRITICAL).** 0.3.1's `suppressTracing` was a no-op because no ContextManager was registered, so the exporter's ingest POST could still be re-traced into a feedback loop. 0.3.2 registers an `AsyncLocalStorageContextManager` (Node + workerd under `nodejs_compat`; sync stack-manager fallback otherwise) so suppression works — and as a bonus you get cross-`await` span parenting + per-request context isolation. **Workers now require `nodejs_compat`.** New dependency: `@opentelemetry/context-async-hooks`.
|
|
162
164
|
- **Hostname-accurate self-span filter** (no sibling-domain false positives; `host:port` now matched; more host-only attrs covered).
|
package/dist/workers.d.ts
CHANGED
|
@@ -253,5 +253,20 @@ type Instrumented<E, H> = Omit<H, "fetch" | "queue" | "scheduled"> & (H extends
|
|
|
253
253
|
} ? {
|
|
254
254
|
scheduled: (controller: ScheduledController, env: E, ctx: ExecutionContext) => Promise<void>;
|
|
255
255
|
} : unknown);
|
|
256
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Recover a handler's concrete env type from whichever traced entrypoint it
|
|
258
|
+
* declares (`fetch`, else `queue`, else `scheduled`). This lets `instrument()`
|
|
259
|
+
* infer the env from the handler argument itself rather than requiring the
|
|
260
|
+
* caller to pass it explicitly — a Worker typed `fetch(req, env: Env, ctx)`
|
|
261
|
+
* type-checks with a bare `instrument(handler, cfg)` call. Falls back to
|
|
262
|
+
* `unknown` for a handler with no recognised entrypoint.
|
|
263
|
+
*/
|
|
264
|
+
type EnvOf<H> = H extends {
|
|
265
|
+
fetch: (req: Request, env: infer E, ctx: ExecutionContext) => unknown;
|
|
266
|
+
} ? E : H extends {
|
|
267
|
+
queue: (batch: MessageBatch, env: infer E, ctx: ExecutionContext) => unknown;
|
|
268
|
+
} ? E : H extends {
|
|
269
|
+
scheduled: (controller: ScheduledController, env: infer E, ctx: ExecutionContext) => unknown;
|
|
270
|
+
} ? E : unknown;
|
|
271
|
+
export declare function instrument<H extends WorkerHandler<any>>(handler: H, config: WorkersConfig): Instrumented<EnvOf<H>, H>;
|
|
257
272
|
export type { Span };
|