UNPKG

@openai/agents-core

Version:

The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.

86 lines • 3.12 kB
import { getGlobalTraceProvider } from "./provider.mjs"; export { getCurrentTraceContext, getCurrentSpan, getCurrentTrace, getOrCreateTrace, resetCurrentSpan, setCurrentSpan, setTracingContextStorage, withTraceContext, withTrace, } from "./context.mjs"; export * from "./createSpans.mjs"; export { BatchTraceProcessor, ConsoleSpanExporter, MultiTracingProcessor, } from "./processor.mjs"; export { NoopSpan, Span } from "./spans.mjs"; export { NoopTrace, Trace } from "./traces.mjs"; export { defaultTracingIdGenerator, generateGroupId, generateSpanId, generateTraceId, } from "./utils.mjs"; /** * Add a processor to the list of processors. Each processor will receive all traces/spans. * * @param processor - The processor to add. */ export function addTraceProcessor(processor) { getGlobalTraceProvider().registerProcessor(processor); } /** * Set the list of processors. This will replace any existing processors. * * @param processors - The list of processors to set. */ export function setTraceProcessors(processors) { getGlobalTraceProvider().setProcessors(processors); } /** * Set the disabled state of the tracing provider. * * @param disabled - Whether to disable tracing. */ export function setTracingDisabled(disabled) { getGlobalTraceProvider().setDisabled(disabled); } /** * Set the trace and span ID generator for the global tracing provider. * * @param idGenerator - Custom ID generator methods, or undefined to restore defaults. */ export function setTracingIdGenerator(idGenerator) { getGlobalTraceProvider().setIdGenerator(idGenerator); } /** * Dispatch a completed trace lifecycle to all processors registered on the * global tracing provider. * * This bypasses Trace.start() and Trace.end(), so callers can replay a * completed lifecycle without mutating the trace state. */ export async function dispatchTrace(trace) { await getGlobalTraceProvider().dispatchTrace(trace); } /** * Dispatch a completed span lifecycle to all processors registered on the * global tracing provider. * * This bypasses Span.start() and Span.end(), so callers can replay a completed * lifecycle without mutating existing timestamps. */ export async function dispatchSpan(span) { await getGlobalTraceProvider().dispatchSpan(span); } /** * Dispatch a span start event to all processors registered on the global * tracing provider. * * This bypasses Span.start(), so callers can emit a start event without * mutating the span state or existing timestamps. */ export async function dispatchSpanStart(span) { await getGlobalTraceProvider().dispatchSpanStart(span); } /** * Dispatch a span end event to all processors registered on the global tracing * provider. * * This bypasses Span.end(), so callers can emit an end event without mutating * the span state or existing timestamps. */ export async function dispatchSpanEnd(span) { await getGlobalTraceProvider().dispatchSpanEnd(span); } /** * Start the trace export loop. */ export function startTraceExportLoop() { getGlobalTraceProvider().startExportLoop(); } //# sourceMappingURL=index.mjs.map