Skip to content

Interface: FusionSpan

Defined in: packages/core/src/observability/Tracing.ts:98

Minimal span interface — structural subtype of OTel's Span.

All methods match OTel's signatures so that an OTel Span satisfies this interface without any adapter.

See

OTel Spec: Span

Methods

addEvent()?

ts
optional addEvent(name, attributes?): void;

Defined in: packages/core/src/observability/Tracing.ts:125

Add a timestamped event to this span.

Optional — not all tracer implementations support events. The pipeline uses span.addEvent?.() (optional chaining).

Parameters

ParameterTypeDescription
namestringEvent name (e.g. 'mcp.route', 'mcp.validate')
attributes?Record<string, FusionAttributeValue>Optional event attributes

Returns

void


end()

ts
end(): void;

Defined in: packages/core/src/observability/Tracing.ts:131

End this span. Must be called exactly once. The pipeline calls this in a finally block to prevent span leaks.

Returns

void


recordException()

ts
recordException(exception): void;

Defined in: packages/core/src/observability/Tracing.ts:139

Record an exception as a span event. Called before setStatus(ERROR) when a handler throws.

Parameters

ParameterTypeDescription
exceptionstring | ErrorThe caught error or string message

Returns

void


setAttribute()

ts
setAttribute(key, value): void;

Defined in: packages/core/src/observability/Tracing.ts:104

Set a single attribute on this span.

Parameters

ParameterTypeDescription
keystringAttribute key (use mcp.* namespace for MCP Fusion attributes)
valueFusionAttributeValuePrimitive or array of primitives

Returns

void


setStatus()

ts
setStatus(status): void;

Defined in: packages/core/src/observability/Tracing.ts:114

Set the span's status.

Use SpanStatusCode.UNSET for AI/validation errors. Use SpanStatusCode.ERROR only for system failures (handler exceptions).

Parameters

ParameterTypeDescription
status{ code: number; message?: string; }Object with code and optional message
status.codenumber-
status.message?string-

Returns

void