Class TraceAnalyzer
java.lang.Object
com.loomcache.server.tracing.TraceAnalyzer
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface for visiting trace nodes.static final classTrace tree node representing a span and its children.static final recordTrace statistics. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable TraceAnalyzer.TraceNodebuildTraceTree(List<SpanManager.Span> spans) Build a trace tree from a list of spans.static @Nullable TraceAnalyzer.TraceNodebuildTraceTreeByTraceId(String traceId, List<SpanManager.Span> spans) Build a trace tree by trace ID from a list of spans.static List<SpanManager.Span> getCriticalPath(List<SpanManager.Span> spans) Get the critical path (longest latency chain) in a trace.static List<SpanManager.Span> getSlowSpans(List<SpanManager.Span> spans, double thresholdMs) Find all spans exceeding a duration threshold.static TraceAnalyzer.TraceStatsgetTraceStats(List<SpanManager.Span> spans) Compute statistics for a trace.
-
Constructor Details
-
TraceAnalyzer
public TraceAnalyzer()
-
-
Method Details
-
buildTraceTree
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
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
Find all spans exceeding a duration threshold.- Parameters:
spans- the spans to searchthresholdMs- the threshold in milliseconds- Returns:
- a list of slow spans
-
getTraceStats
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 IDspans- the spans to search- Returns:
- the root node of the trace tree (or null if no matching spans)
-