diff

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package diff computes a structural/timing comparison between two sessions' spans. It is shared by the HTTP API (/api/diff) and the MCP diff_sessions tool. JSON tags match the original API wire format.

Index

Constants

View Source
const ZeroParent = "0000000000000000"

ZeroParent is the all-zero parent span id some exporters use for roots.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Baseline      SessionInfo     `json:"baseline"`
	Compare       SessionInfo     `json:"compare"`
	Summary       Summary         `json:"summary"`
	Spans         []Span          `json:"spans"`
	BaselineSpans []*storage.Span `json:"baseline_spans"`
	CompareSpans  []*storage.Span `json:"compare_spans"`
}

func Compute

func Compute(
	baseSess, cmpSess *storage.Session,
	baseSpans, cmpSpans []*storage.Span,
) Result

Compute diffs baseline vs compare sessions by their spans.

type SessionInfo

type SessionInfo struct {
	SessionID       string `json:"session_id"`
	Label           string `json:"label"`
	TotalDurationNs int64  `json:"total_duration_ns"`
	SpanCount       int    `json:"span_count"`
	DBCalls         int    `json:"db_calls"`
}

type Span

type Span struct {
	Name               string  `json:"name"`
	ServiceName        string  `json:"service_name"`
	Status             string  `json:"status"` // added|removed|changed|unchanged
	BaselineDurationNs int64   `json:"baseline_duration_ns"`
	CompareDurationNs  int64   `json:"compare_duration_ns"`
	DeltaPct           float64 `json:"delta_pct"`
	Depth              int     `json:"depth"`
}

Span is one (service, operation) row in a diff.

type Summary

type Summary struct {
	DurationDeltaNs  int64   `json:"duration_delta_ns"`
	DurationDeltaPct float64 `json:"duration_delta_pct"`
	SpansAdded       int     `json:"spans_added"`
	SpansRemoved     int     `json:"spans_removed"`
	DBCallDelta      int     `json:"db_call_delta"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL