• Emits a distributed trace span to the configured telemetry sink (e.g., OpenTelemetry). The span is linked to the workflow's trace context (traceId, spanId) for end-to-end observability across workflow executions, activities, and child workflows.

    By default (config.once = true), the trace is emitted exactly once per workflow execution — it will not re-fire on replay.

    import { Durable } from '@hotmeshio/hotmesh';

    // Emit trace spans at key workflow milestones
    export async function orderWorkflow(orderId: string): Promise<void> {
    await Durable.workflow.trace({
    'order.id': orderId,
    'order.stage': 'started',
    });

    const { processPayment } = Durable.workflow.proxyActivities<typeof activities>();
    await processPayment(orderId);

    await Durable.workflow.trace({
    'order.id': orderId,
    'order.stage': 'payment_completed',
    });
    }
    // Trace on every re-execution (for debugging replay behavior)
    await Durable.workflow.trace(
    { 'debug.counter': counter, 'debug.phase': 'retry' },
    { once: false },
    );

    Parameters

    • attributes: StringScalarType

      Key-value attributes to attach to the trace span.

    • Optionalconfig: {
          once: boolean;
      } = ...

      If true, trace fires only once (idempotent).

      • once: boolean

    Returns Promise<boolean>

    true if tracing succeeded.