Class InMemoryTraceExporter

java.lang.Object
com.loomcache.server.tracing.InMemoryTraceExporter
All Implemented Interfaces:
TraceExporter

public class InMemoryTraceExporter extends Object implements 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 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

      public void export(List<SpanManager.Span> spanList)
      Export spans to memory.
      Specified by:
      export in interface TraceExporter
      Parameters:
      spanList - the spans to export
    • getSpans

      public List<SpanManager.Span> getSpans()
      Get all stored spans (copy).
      Returns:
      a list of all stored spans
    • getSpansByTraceId

      public List<SpanManager.Span> getSpansByTraceId(String traceId)
      Get spans by trace ID.
      Parameters:
      traceId - the trace ID to search for
      Returns:
      a list of spans matching the trace ID
    • getSpansByOperation

      public List<SpanManager.Span> getSpansByOperation(String operationName)
      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: TraceExporter
      Shutdown the exporter and release any resources.
      Specified by:
      shutdown in interface TraceExporter