@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 27 lines 731 Bytes
Raw
1 import * as Layer from "effect/Layer";
2 import * as Tracer from "effect/Tracer";
3
4 import { randomUUID } from "../lib/utils";
5
6 /** `service.instance.id` for this page load, shared by every resource the UI exports. */
7 export const serviceInstanceId = randomUUID();
8
9 let delegate: Tracer.Tracer | null = null;
10
11 export function setDelegate(next: Tracer.Tracer | null): void {
12 delegate = next;
13 }
14
15 export function hasDelegate(): boolean {
16 return delegate !== null;
17 }
18
19 // Install before exporters exist so spans reach whichever exporter is configured later.
20 export const layer = Layer.succeed(
21 Tracer.Tracer,
22 Tracer.make({
23 span(options) {
24 return delegate?.span(options) ?? new Tracer.NativeSpan(options);
25 },
26 }),
27 );