MemorySpanProcessor implements SpanProcessor
Processor that stores spans in memory and exports via configured exporter.
Interfaces
- SpanProcessor
- Interface for processing spans when they start and end.
Methods
- __construct() : mixed
- endedSpans() : array<string|int, Span>
- Get all spans that have ended.
- endedSpansForTrace() : array<string|int, Span>
- Get all ended spans for a specific trace.
- flush() : bool
- Export all pending spans and return success status.
- onEnd() : void
- Called when a span ends.
- onStart() : void
- Called when a span starts.
- reset() : void
- shutdown() : void
- Shutdown the processor.
- startedSpans() : array<string|int, Span>
- Get all spans that have started.
- startedSpansForTrace() : array<string|int, Span>
- Get all started spans for a specific trace.
- traceIds() : array<string|int, string>
- Get all trace IDs that have spans recorded.
Methods
__construct()
public
__construct(Exporter $spanExporter[, ErrorHandler $errorHandler = new ErrorLogHandler() ]) : mixed
Parameters
- $spanExporter : Exporter
- $errorHandler : ErrorHandler = new ErrorLogHandler()
endedSpans()
Get all spans that have ended.
public
endedSpans() : array<string|int, Span>
Return values
array<string|int, Span>endedSpansForTrace()
Get all ended spans for a specific trace.
public
endedSpansForTrace(string $traceId) : array<string|int, Span>
Parameters
- $traceId : string
Return values
array<string|int, Span>flush()
Export all pending spans and return success status.
public
flush() : bool
Forces immediate export of any buffered spans. Returns true if all spans were successfully exported.
Return values
boolonEnd()
Called when a span ends.
public
onEnd(Span $span) : void
This is invoked synchronously when the span completes. The span is fully populated at this point (end time, status, all attributes).
Parameters
- $span : Span
onStart()
Called when a span starts.
public
onStart(Span $span) : void
This is invoked synchronously when the span begins. Implementations should avoid blocking operations in this method.
Parameters
- $span : Span
reset()
public
reset() : void
shutdown()
Shutdown the processor.
public
shutdown() : void
Implementations SHOULD flush() pending data before delegating shutdown to the underlying exporter. MUST be idempotent and MUST NOT throw.
startedSpans()
Get all spans that have started.
public
startedSpans() : array<string|int, Span>
Return values
array<string|int, Span>startedSpansForTrace()
Get all started spans for a specific trace.
public
startedSpansForTrace(string $traceId) : array<string|int, Span>
Parameters
- $traceId : string
Return values
array<string|int, Span>traceIds()
Get all trace IDs that have spans recorded.
public
traceIds() : array<string|int, string>