| 1 | import { describe, expect, it } from "@effect/vitest"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Tracer from "effect/Tracer"; |
| 4 | |
| 5 | import * as ClientTracer from "../observability/clientTracer"; |
| 6 | import { runtime } from "./runtime"; |
| 7 | |
| 8 | describe("web runtime", () => { |
| 9 | it("routes client spans to the exporter client tracing configured", async () => { |
| 10 | const exported: Array<string> = []; |
| 11 | ClientTracer.setDelegate( |
| 12 | Tracer.make({ |
| 13 | span(options) { |
| 14 | exported.push(options.name); |
| 15 | return new Tracer.NativeSpan(options); |
| 16 | }, |
| 17 | }), |
| 18 | ); |
| 19 | |
| 20 | try { |
| 21 | await runtime.runPromise(Effect.void.pipe(Effect.withSpan("client.work"))); |
| 22 | } finally { |
| 23 | ClientTracer.setDelegate(null); |
| 24 | } |
| 25 | |
| 26 | expect(exported).toEqual(["client.work"]); |
| 27 | }); |
| 28 | }); |