Class InMemoryTraceExporter
java.lang.Object
com.loomcache.server.tracing.InMemoryTraceExporter
- All Implemented Interfaces:
TraceExporter
In-memory trace exporter for testing and debugging.
Features
- Stores spans in a bounded queue (memory-efficient) - Thread-safe operations - Supports querying spans by trace ID - Automatic expiration of old spans (configurable)- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an in-memory exporter with default capacity (10,000 spans).InMemoryTraceExporter(int maxSpans) Create an in-memory exporter with specified capacity. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear all stored spans.voidexport(List<SpanManager.Span> spanList) Export spans to memory.longGet the total number of spans exported.intGet the maximum capacity.intGet the number of stored spans.getSpans()Get all stored spans (copy).getSpansByOperation(String operationName) Get spans by operation name.getSpansByTraceId(String traceId) Get spans by trace ID.voidshutdown()Shutdown the exporter and release any resources.
-
Constructor Details
-
InMemoryTraceExporter
public InMemoryTraceExporter()Create an in-memory exporter with default capacity (10,000 spans). -
InMemoryTraceExporter
public InMemoryTraceExporter(int maxSpans) Create an in-memory exporter with specified capacity.- Parameters:
maxSpans- maximum number of spans to store
-
-
Method Details
-
export
Export spans to memory.- Specified by:
exportin interfaceTraceExporter- Parameters:
spanList- the spans to export
-
getSpans
Get all stored spans (copy).- Returns:
- a list of all stored spans
-
getSpansByTraceId
Get spans by trace ID.- Parameters:
traceId- the trace ID to search for- Returns:
- a list of spans matching the trace ID
-
getSpansByOperation
Get spans by operation name.- Parameters:
operationName- the operation name to search for- Returns:
- a list of spans matching the operation name
-
clear
public void clear()Clear all stored spans. -
getSpanCount
public int getSpanCount()Get the number of stored spans.- Returns:
- the current span count
-
getExportedCount
public long getExportedCount()Get the total number of spans exported.- Returns:
- the exported span count
-
getMaxCapacity
public int getMaxCapacity()Get the maximum capacity.- Returns:
- the max spans
-
shutdown
public void shutdown()Description copied from interface:TraceExporterShutdown the exporter and release any resources.- Specified by:
shutdownin interfaceTraceExporter
-