IFClite TypeScript API
    Preparing search index...

    Interface WorkerPhaseTrace

    Spans for the phases INSIDE one long worker handler (#6979), where createWorkerTraceHost's one-span-per-message is too coarse. The parser worker runs a whole parse in a single parse message and the host terminates it the moment complete arrives, so a span posted after the handler settles would die with the worker: flush() posts what has finished so far, and the worker calls it before any message after which it may be terminated.

    Enabled by the same enableWorkerTrace request as the host. Until then every method is a null check, so an untraced load pays nothing measurable.

    interface WorkerPhaseTrace {
        enabled: boolean;
        accept(data: unknown): boolean;
        begin(
            name: string,
            attrs?: Readonly<Record<string, TraceAttrValue>>,
        ): number;
        end(token: number, attrs?: Readonly<Record<string, TraceAttrValue>>): void;
        flush(): void;
        span<T>(
            name: string,
            fn: () => T,
            attrs?: Readonly<Record<string, TraceAttrValue>>,
        ): T;
        step(name: string | null): void;
    }
    Index
    enabled: boolean
    • Feed each inbound message first; true = it was the enable request (consumed).

      Parameters

      • data: unknown

      Returns boolean

    • Open a span; -1 when disabled.

      Parameters

      Returns number

    • Parameters

      • token: number
      • Optionalattrs: Readonly<Record<string, TraceAttrValue>>

      Returns void

    • Post every finished span now (nothing when there are none).

      Returns void

    • Time fn; a returned promise ends the span when it settles. Returns fn's result unchanged.

      Type Parameters

      • T

      Parameters

      • name: string
      • fn: () => T
      • Optionalattrs: Readonly<Record<string, TraceAttrValue>>

      Returns T

    • Sequential phases: end the previous step span and open name (or just end it, for null). A repeated name keeps the open span, so a progress callback that reports one phase many times can drive this directly.

      Parameters

      • name: string | null

      Returns void