Class TraceAnalyzer

java.lang.Object
com.loomcache.server.tracing.TraceAnalyzer

public class TraceAnalyzer extends Object
Analyzer for distributed traces.

Features

- Build trace trees from spans - Identify critical paths (longest latency) - Find slow spans exceeding thresholds - Compute trace statistics
Since:
1.0
  • Constructor Details

    • TraceAnalyzer

      public TraceAnalyzer()
  • Method Details

    • buildTraceTree

      public static @Nullable TraceAnalyzer.TraceNode buildTraceTree(List<SpanManager.Span> spans)
      Build a trace tree from a list of spans.
      Parameters:
      spans - the spans to organize
      Returns:
      the root node of the trace tree (or null if no spans)
    • getCriticalPath

      public static List<SpanManager.Span> getCriticalPath(List<SpanManager.Span> spans)
      Get the critical path (longest latency chain) in a trace.
      Parameters:
      spans - the spans in the trace
      Returns:
      a list of spans representing the critical path
    • getSlowSpans

      public static List<SpanManager.Span> getSlowSpans(List<SpanManager.Span> spans, double thresholdMs)
      Find all spans exceeding a duration threshold.
      Parameters:
      spans - the spans to search
      thresholdMs - the threshold in milliseconds
      Returns:
      a list of slow spans
    • getTraceStats

      public static TraceAnalyzer.TraceStats getTraceStats(List<SpanManager.Span> spans)
      Compute statistics for a trace.
      Parameters:
      spans - the spans in the trace
      Returns:
      trace statistics
    • buildTraceTreeByTraceId

      public static @Nullable TraceAnalyzer.TraceNode buildTraceTreeByTraceId(String traceId, List<SpanManager.Span> spans)
      Build a trace tree by trace ID from a list of spans.
      Parameters:
      traceId - the trace ID
      spans - the spans to search
      Returns:
      the root node of the trace tree (or null if no matching spans)