@mastra/core
Version:
136 lines (135 loc) • 5.65 kB
JavaScript
//#region src/observability/types/tracing.ts
/**
* Tracing interfaces
*
* Span types, attributes, span lifecycle, and tracing-specific types.
* For top-level observability infrastructure (instances, exporters, bridges, config),
* see observability.ts.
*/
/**
* AI-specific span types with their associated metadata
*/
let SpanType = /* @__PURE__ */ function(SpanType) {
/** Agent run - root span for agent processes */
SpanType["AGENT_RUN"] = "agent_run";
/** Scorer execution */
SpanType["SCORER_RUN"] = "scorer_run";
/** Individual scorer pipeline step */
SpanType["SCORER_STEP"] = "scorer_step";
/** Generic span for custom operations */
SpanType["GENERIC"] = "generic";
/** Model generation with model calls, token usage, prompts, completions */
SpanType["MODEL_GENERATION"] = "model_generation";
/** Single model execution step within a generation (one API call) */
SpanType["MODEL_STEP"] = "model_step";
/** Model provider call within a step - wraps only the inference, excluding processors and tool executions */
SpanType["MODEL_INFERENCE"] = "model_inference";
/** Individual model streaming chunk/event */
SpanType["MODEL_CHUNK"] = "model_chunk";
/** MCP (Model Context Protocol) tool execution */
SpanType["MCP_TOOL_CALL"] = "mcp_tool_call";
/** Input or Output Processor execution */
SpanType["PROCESSOR_RUN"] = "processor_run";
/** Function/tool execution with inputs, outputs, errors */
SpanType["TOOL_CALL"] = "tool_call";
/**
* Client-side tool execution marker. The server creates this span
* when the model emits a client tool call, injects its W3C carrier
* into the outgoing tool-call chunk, then ends the span once tool
* args are available. Child spans/logs from inside the client tool's
* execute function flow back as OTLP/JSON via the ClientObservabilityProxy
* interface in @mastra/observability and parent themselves under this
* span via parentSpanId reference.
*/
SpanType["CLIENT_TOOL_CALL"] = "client_tool_call";
/**
* Provider-executed (server-side) tool span. Reconstructed from
* tool-call and tool-result stream chunks for tools the model
* provider executes (e.g. Anthropic code execution, server-side
* web search). Created on the tool-result chunk under the model
* step that delivered it, with the start time backdated to the
* tool-call chunk.
*/
SpanType["PROVIDER_TOOL_CALL"] = "provider_tool_call";
/** Workflow run - root span for workflow processes */
SpanType["WORKFLOW_RUN"] = "workflow_run";
/** Workflow step execution with step status, data flow */
SpanType["WORKFLOW_STEP"] = "workflow_step";
/** Workflow conditional execution with condition evaluation */
SpanType["WORKFLOW_CONDITIONAL"] = "workflow_conditional";
/** Individual condition evaluation within conditional */
SpanType["WORKFLOW_CONDITIONAL_EVAL"] = "workflow_conditional_eval";
/** Workflow parallel execution */
SpanType["WORKFLOW_PARALLEL"] = "workflow_parallel";
/** Workflow loop execution */
SpanType["WORKFLOW_LOOP"] = "workflow_loop";
/** Workflow sleep operation */
SpanType["WORKFLOW_SLEEP"] = "workflow_sleep";
/** Workflow wait for event operation */
SpanType["WORKFLOW_WAIT_EVENT"] = "workflow_wait_event";
/** Memory operation (recall, save, delete, update working memory) */
SpanType["MEMORY_OPERATION"] = "memory_operation";
/** Workspace action (filesystem, sandbox, search, skill, mount operations) */
SpanType["WORKSPACE_ACTION"] = "workspace_action";
/** RAG ingestion - root span for an ingestion pipeline run (load → chunk → extract → embed → upsert) */
SpanType["RAG_INGESTION"] = "rag_ingestion";
/** Embedding call (used by both RAG ingestion and query) */
SpanType["RAG_EMBEDDING"] = "rag_embedding";
/** Vector store I/O (query / upsert / delete / fetch) */
SpanType["RAG_VECTOR_OPERATION"] = "rag_vector_operation";
/** RAG-specific actions: chunk, extract_metadata, rerank */
SpanType["RAG_ACTION"] = "rag_action";
/** Graph operations (build / traverse) - not RAG-specific */
SpanType["GRAPH_ACTION"] = "graph_action";
/** Inline data mapping between pipeline stages (e.g. a tool's `toModelOutput` transform) */
SpanType["MAPPING"] = "mapping";
return SpanType;
}({});
/**
* Bitwise options to set different types of spans as internal in
* a workflow or agent execution.
*/
let InternalSpans = /* @__PURE__ */ function(InternalSpans) {
/** No spans are marked internal */
InternalSpans[InternalSpans["NONE"] = 0] = "NONE";
/** Workflow spans are marked internal */
InternalSpans[InternalSpans["WORKFLOW"] = 1] = "WORKFLOW";
/** Agent spans are marked internal */
InternalSpans[InternalSpans["AGENT"] = 2] = "AGENT";
/** Tool spans are marked internal */
InternalSpans[InternalSpans["TOOL"] = 4] = "TOOL";
/** Model spans are marked internal */
InternalSpans[InternalSpans["MODEL"] = 8] = "MODEL";
/** All spans are marked internal */
InternalSpans[InternalSpans["ALL"] = 15] = "ALL";
return InternalSpans;
}({});
/**
* Tracing event types
*/
let TracingEventType = /* @__PURE__ */ function(TracingEventType) {
TracingEventType["SPAN_STARTED"] = "span_started";
TracingEventType["SPAN_UPDATED"] = "span_updated";
TracingEventType["SPAN_ENDED"] = "span_ended";
return TracingEventType;
}({});
//#endregion
Object.defineProperty(exports, "InternalSpans", {
enumerable: true,
get: function() {
return InternalSpans;
}
});
Object.defineProperty(exports, "SpanType", {
enumerable: true,
get: function() {
return SpanType;
}
});
Object.defineProperty(exports, "TracingEventType", {
enumerable: true,
get: function() {
return TracingEventType;
}
});
//# sourceMappingURL=tracing-BUrUJwCM.cjs.map