archive

package
v1.9.15 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Export

func Export(src, dst string, format ExportFormat, filter *Filter, progress func(ExportProgress)) error

Export reads filtered entries from src and writes to dst in the given format.

func FormatBytes

func FormatBytes(b int64) string

FormatBytes formats byte counts in human-readable form.

func FormatCount

func FormatCount(n int64) string

FormatCount formats large numbers with comma separators.

func IsError

func IsError(msg string) bool

IsError returns true if the message contains common error-indicating keywords.

func Merge added in v0.3.0

func Merge(sources []string, dst string, progress func(MergeProgress)) error

Merge combines multiple capture directories into one by copying compressed files without decompressing. The output index.jsonl is sorted by timestamp.

func NewInjector added in v1.4.0

func NewInjector(faults []FaultConfig) func(recv.LogEntry) []recv.LogEntry

NewInjector creates a transform function that applies fault injection. Entries outside the fault window pass through unchanged.

func NormalizeMessage

func NormalizeMessage(msg string) string

NormalizeMessage replaces variable tokens (UUIDs, IPs, timestamps, etc.) with placeholders to produce a stable signature for grouping similar messages.

func Pack added in v0.3.0

func Pack(src, dst string) error

Pack creates a tar.zst archive from a capture directory.

func ParseTimeFlag

func ParseTimeFlag(s string, refDate, refTime time.Time) (time.Time, error)

ParseTimeFlag parses a time string in one of three formats: - RFC3339: "2024-01-15T10:32:00Z" - HH:MM: "10:32" — resolved against refDate - Relative: "-30m" — resolved against refTime

func RewriteWithOffset added in v1.5.0

func RewriteWithOffset(src, dst string, offset time.Duration) (int64, error)

RewriteWithOffset reads entries from src, adjusts timestamps by offset, and writes to dst.

func Slice

func Slice(opts SliceOptions) error

Slice performs the slicing operation.

func Unpack added in v0.3.0

func Unpack(src, dst string) error

Unpack extracts a tar.zst archive to a directory and validates the capture.

func WriteCatalogJSON added in v1.1.0

func WriteCatalogJSON(w io.Writer, entries []CatalogEntry) error

WriteCatalogJSON writes catalog entries as JSON.

func WriteCatalogText added in v1.1.0

func WriteCatalogText(w io.Writer, entries []CatalogEntry)

WriteCatalogText writes catalog entries as a formatted table.

func WriteIndex added in v1.0.6

func WriteIndex(dir string, index *Index) error

WriteIndex writes the Index struct to index.jsonl in the specified directory.

func WriteMetadata added in v1.0.6

func WriteMetadata(dir string, meta *Metadata) error

WriteMetadata writes the Metadata struct to metadata.json in the specified directory.

Types

type BaselineDiffResult added in v1.2.0

type BaselineDiffResult struct {
	Baseline         string       `json:"baseline"`
	Current          string       `json:"current"`
	ErrorRateChange  string       `json:"error_rate_change"`
	VolumeChange     string       `json:"volume_change"`
	NewErrorPatterns []ErrorDelta `json:"new_error_patterns,omitempty"`
	MissingLabels    []string     `json:"missing_labels,omitempty"`
	NewLabels        []string     `json:"new_labels,omitempty"`
	Verdict          string       `json:"verdict"`
	Confidence       float64      `json:"confidence"`
}

BaselineDiffResult holds a verdict-oriented comparison against a baseline capture.

func BaselineDiff added in v1.2.0

func BaselineDiff(baselineDir, currentDir string) (*BaselineDiffResult, error)

BaselineDiff compares a current capture against a baseline, producing a verdict. baselineDir is the known-good reference; currentDir is the capture under evaluation.

func (*BaselineDiffResult) WriteJSON added in v1.2.0

func (b *BaselineDiffResult) WriteJSON(w io.Writer) error

WriteJSON writes the baseline diff result as JSON.

func (*BaselineDiffResult) WriteText added in v1.2.0

func (b *BaselineDiffResult) WriteText(w io.Writer)

WriteText writes a human-readable baseline diff summary.

type Bucket

type Bucket struct {
	Time  time.Time `json:"time"`
	Lines int64     `json:"lines"`
}

Bucket represents a 1-minute timeline bucket.

type CatalogEntry added in v1.1.0

type CatalogEntry struct {
	Dir     string    `json:"dir"`
	Started time.Time `json:"started"`
	Stopped time.Time `json:"stopped,omitempty"`
	Files   int       `json:"files"`
	Entries int64     `json:"entries"`
	Bytes   int64     `json:"bytes"`
	Active  bool      `json:"active"`
	Labels  []string  `json:"labels,omitempty"`
}

CatalogEntry represents one discovered capture directory.

func Catalog added in v1.1.0

func Catalog(root string, recursive bool) ([]CatalogEntry, error)

Catalog scans root for capture directories containing metadata.json. If recursive is true, it walks subdirectories.

type ClockCorrection added in v1.5.0

type ClockCorrection struct {
	Source     string  `json:"source"`
	OffsetMs   int64   `json:"offset_ms"`
	Confidence float64 `json:"confidence"`
	Method     string  `json:"method"`
}

ClockCorrection describes a detected clock offset for one source.

func DetectSkew added in v1.5.0

func DetectSkew(sources []string) ([]ClockCorrection, error)

DetectSkew compares error signature timestamps across sources to estimate clock offsets. Returns one ClockCorrection per non-reference source. Sources with no detectable skew or skew exceeding maxSkewCorrection are omitted.

func MergeWithCorrection added in v1.5.0

func MergeWithCorrection(sources []string, dst string, progress func(MergeProgress)) ([]ClockCorrection, error)

MergeWithCorrection detects clock skew between sources, rewrites skewed captures with adjusted timestamps, then merges everything into dst.

type Correlation added in v1.2.0

type Correlation struct {
	Source      string  `json:"source"`       // service that failed first
	Target      string  `json:"target"`       // service that failed after
	LagSeconds  float64 `json:"lag_seconds"`  // time between source and target errors
	Pattern     string  `json:"pattern"`      // cascade_timeout, cascade_error, co_failure
	Confidence  float64 `json:"confidence"`   // 0.0-1.0
	SourceError string  `json:"source_error"` // first error from source
	TargetError string  `json:"target_error"` // first error from target
}

Correlation represents a detected temporal error pattern between two services.

func Correlate added in v1.2.0

func Correlate(dir string, windowSize time.Duration) ([]Correlation, error)

Correlate analyzes error entries grouped by label to detect temporal cascade patterns.

type DiffCapture added in v0.3.0

type DiffCapture struct {
	Dir       string        `json:"dir"`
	Started   time.Time     `json:"started"`
	Stopped   time.Time     `json:"stopped"`
	Duration  time.Duration `json:"duration"`
	Lines     int64         `json:"lines"`
	LinesPerS float64       `json:"lines_per_sec"`
	Labels    []string      `json:"labels"`
}

DiffCapture summarizes one side of the comparison.

type DiffResult added in v0.3.0

type DiffResult struct {
	A DiffCapture `json:"a"`
	B DiffCapture `json:"b"`

	LabelsOnlyA []string       `json:"labels_only_a,omitempty"`
	LabelsOnlyB []string       `json:"labels_only_b,omitempty"`
	ErrorsOnlyA []ErrorSummary `json:"errors_only_a,omitempty"`
	ErrorsOnlyB []ErrorSummary `json:"errors_only_b,omitempty"`
	RateCompare []RateBucket   `json:"rate_compare,omitempty"`
}

DiffResult holds the comparison between two captures.

func Diff added in v0.3.0

func Diff(srcA, srcB string) (*DiffResult, error)

Diff compares two capture directories.

func (*DiffResult) WriteJSON added in v0.3.0

func (d *DiffResult) WriteJSON(w io.Writer) error

WriteJSON writes the diff result as JSON.

func (*DiffResult) WriteText added in v0.3.0

func (d *DiffResult) WriteText(w io.Writer)

WriteText writes a human-readable diff summary.

type ErrorDelta added in v1.2.0

type ErrorDelta struct {
	Pattern       string `json:"pattern"`
	Count         int64  `json:"count"`
	BaselineCount int64  `json:"baseline_count"`
}

ErrorDelta describes an error pattern that is new or significantly worse in the current capture.

type ErrorSignature

type ErrorSignature struct {
	Signature string    `json:"signature"`
	Count     int64     `json:"count"`
	FirstSeen time.Time `json:"first_seen"`
	Example   string    `json:"example"`
}

ErrorSignature represents a normalized error pattern.

type ErrorSummary added in v0.3.0

type ErrorSummary struct {
	Pattern string `json:"pattern"`
	Count   int64  `json:"count"`
}

ErrorSummary is a simplified error pattern with count.

type ExportFormat

type ExportFormat string

ExportFormat identifies the output format.

const (
	FormatParquet ExportFormat = "parquet"
	FormatCSV     ExportFormat = "csv"
	FormatJSONL   ExportFormat = "jsonl"
)

type ExportProgress

type ExportProgress struct {
	Written int64
	Total   int64 // source total lines from index
}

ExportProgress reports progress during export.

type ExportWriter

type ExportWriter interface {
	Write(recv.LogEntry) error
	Close() error
}

ExportWriter writes log entries to an output format.

type FaultConfig added in v1.4.0

type FaultConfig struct {
	Type     FaultType
	Service  string        // target service (for service-down, latency-spike)
	At       time.Time     // when to start injection
	Duration time.Duration // how long the fault lasts
}

FaultConfig describes a fault injection.

func ParseFault added in v1.4.0

func ParseFault(spec string) (FaultConfig, error)

ParseFault parses a fault spec string. Formats: "error-spike", "service-down=payment", "latency-spike=api".

type FaultType added in v1.4.0

type FaultType string

FaultType identifies the kind of fault to inject.

const (
	FaultErrorSpike   FaultType = "error-spike"
	FaultServiceDown  FaultType = "service-down"
	FaultLatencySpike FaultType = "latency-spike"
)

type Feeder

type Feeder struct {
	// contains filtered or unexported fields
}

Feeder pushes entries from a Reader into a LogRing at controlled speed.

func NewFeeder

func NewFeeder(reader *Reader, ring *recv.LogRing, filter *Filter, speed Speed) *Feeder

NewFeeder creates a feeder wired to the given reader, ring, and filter.

func (*Feeder) Done

func (f *Feeder) Done() bool

Done returns true when scanning has completed.

func (*Feeder) Err

func (f *Feeder) Err() error

Err returns any error from scanning.

func (*Feeder) LinesEmitted

func (f *Feeder) LinesEmitted() int64

LinesEmitted returns the count of entries pushed to the ring.

func (*Feeder) Paused

func (f *Feeder) Paused() bool

Paused returns whether the feeder is paused.

func (*Feeder) SetLabelFilter added in v1.9.2

func (f *Feeder) SetLabelFilter(fn func(recv.LogEntry) bool)

SetLabelFilter sets a predicate that entries must pass before being pushed. Must be called before Start.

func (*Feeder) SetSpeed

func (f *Feeder) SetSpeed(s Speed)

SetSpeed changes the replay speed, recalculating the timeline anchor.

func (*Feeder) SetTransform added in v1.4.0

func (f *Feeder) SetTransform(fn func(recv.LogEntry) []recv.LogEntry)

SetTransform sets a transform function that processes each entry before pushing. The transform may return zero, one, or many entries per input entry.

func (*Feeder) Speed

func (f *Feeder) Speed() Speed

Speed returns current replay speed.

func (*Feeder) Start

func (f *Feeder) Start()

Start launches the feeder goroutine.

func (*Feeder) Stop

func (f *Feeder) Stop()

Stop cancels the feeder and waits for completion.

func (*Feeder) TogglePause

func (f *Feeder) TogglePause() bool

TogglePause toggles pause state. Returns new paused state.

type FileDigest added in v1.4.0

type FileDigest struct {
	File   string `json:"file"`
	SHA256 string `json:"sha256"`
	Bytes  int64  `json:"bytes"`
}

FileDigest is a single file's SHA256 hash and size.

type FileInfo

type FileInfo struct {
	Path   string
	Name   string
	Index  *rotate.IndexEntry // nil for orphan files
	Orphan bool
}

FileInfo describes a data file in a capture directory.

type FileMismatch added in v1.4.0

type FileMismatch struct {
	File     string `json:"file"`
	Expected string `json:"expected"`
	Actual   string `json:"actual"`
}

FileMismatch records a hash mismatch between manifest and actual file.

type Filter

type Filter struct {
	From   time.Time
	To     time.Time
	Labels []LabelMatcher
	Grep   *regexp.Regexp
}

Filter provides two-tier filtering: file-level skip and entry-level match.

func (*Filter) MatchEntry

func (f *Filter) MatchEntry(e recv.LogEntry) bool

MatchEntry returns true if the entry passes all filter criteria.

func (*Filter) SkipFile

func (f *Filter) SkipFile(idx *rotate.IndexEntry) bool

SkipFile returns true if the entire file can be skipped based on index metadata.

type GCDeletion added in v1.0.0

type GCDeletion struct {
	Dir       string    `json:"dir"`
	Started   time.Time `json:"started"`
	SizeBytes int64     `json:"size_bytes"`
	Reasons   []string  `json:"reasons,omitempty"`
}

GCDeletion records a capture directory selected for deletion.

type GCOptions added in v1.0.0

type GCOptions struct {
	MaxAge        time.Duration
	MaxTotalBytes int64
	DryRun        bool
	Now           time.Time
}

GCOptions configures garbage collection of capture directories.

type GCResult added in v1.0.0

type GCResult struct {
	Root          string        `json:"root"`
	CaptureCount  int           `json:"capture_count"`
	TotalBytes    int64         `json:"total_bytes"`
	MaxAge        time.Duration `json:"max_age,omitempty"`
	MaxTotalBytes int64         `json:"max_total_bytes,omitempty"`
	DryRun        bool          `json:"dry_run"`
	Deletions     []GCDeletion  `json:"deletions"`
	// contains filtered or unexported fields
}

GCResult summarizes a GC run.

func GC added in v1.0.0

func GC(root string, opts GCOptions) (*GCResult, error)

GC scans subdirectories of root and deletes old or oversized captures.

func (*GCResult) WriteJSON added in v1.0.0

func (r *GCResult) WriteJSON(w io.Writer) error

WriteJSON writes the deletion list as indented JSON.

func (*GCResult) WriteText added in v1.0.0

func (r *GCResult) WriteText(w io.Writer)

WriteText writes a human-readable GC summary.

type GrepConfig added in v0.3.0

type GrepConfig struct {
	CountOnly bool // only report per-file counts, do not call onMatch
	Context   int  // number of surrounding lines to include (0 = matches only)
}

GrepConfig controls grep behavior.

type GrepFileCount added in v0.3.0

type GrepFileCount struct {
	File  string
	Count int64
}

GrepFileCount holds the match count for a single file.

func Grep added in v0.3.0

func Grep(src string, filter *Filter, cfg GrepConfig,
	onMatch func(GrepMatch), progress func(GrepProgress)) ([]GrepFileCount, error)

Grep searches a capture directory for entries matching the filter. In default mode, calls onMatch for each matching entry. Returns per-file counts (only files with matches) and any error.

type GrepMatch added in v0.3.0

type GrepMatch struct {
	File    string
	Entry   recv.LogEntry
	Context string // "" for actual match, "before" or "after" for context lines
	Group   int    // context group ID (0 when context is not used); entries in the same group are contiguous
}

GrepMatch represents a matching entry with file context.

type GrepProgress added in v0.3.0

type GrepProgress struct {
	Scanned int64
	Total   int64
	Matches int64
}

GrepProgress reports progress during grep scanning.

type Index added in v1.0.6

type Index struct {
	Entries []IndexEntry `json:"entries"`
}

Index represents the structure of index.jsonl

func NewIndex added in v1.0.6

func NewIndex() *Index

NewIndex creates a new Index instance.

func ReadIndex added in v1.0.6

func ReadIndex(dir string) (*Index, error)

ReadIndex reads the index.jsonl file from the specified directory.

type IndexEntry added in v1.0.6

type IndexEntry struct {
	File   string                    `json:"file"`
	From   time.Time                 `json:"from"`
	To     time.Time                 `json:"to"`
	Lines  int64                     `json:"lines"`
	Bytes  int64                     `json:"bytes"`
	Labels map[string]map[string]int `json:"labels"`
}

IndexEntry represents a single entry in index.jsonl

type InjectWriteResult added in v1.4.0

type InjectWriteResult struct {
	Source        string `json:"source"`
	Output        string `json:"output"`
	OriginalLines int64  `json:"original_lines"`
	InjectedLines int64  `json:"injected_lines"`
	TotalLines    int64  `json:"total_lines"`
	Faults        int    `json:"faults_applied"`
}

InjectWriteResult describes the output of a fault-injection write.

func InjectWrite added in v1.4.0

func InjectWrite(src, dst string, filter *Filter, faults []FaultConfig) (*InjectWriteResult, error)

InjectWrite reads entries from a capture, applies fault injection, and writes the modified stream to a new capture directory.

func (*InjectWriteResult) WriteJSON added in v1.4.0

func (r *InjectWriteResult) WriteJSON(w io.Writer) error

WriteJSON writes the result as JSON to w.

func (*InjectWriteResult) WriteText added in v1.4.0

func (r *InjectWriteResult) WriteText(w io.Writer)

WriteText writes the result as human-readable text to w.

type Interaction added in v1.4.0

type Interaction struct {
	From       string  `json:"from"`
	To         string  `json:"to"`
	LagSeconds float64 `json:"lag_seconds"`
	Pattern    string  `json:"pattern"`
	Confidence float64 `json:"confidence"`
	Label      string  `json:"label"`
}

Interaction represents an arrow between two participants.

type LabelFilter added in v1.0.6

type LabelFilter struct {
	Key   string
	Value string
}

LabelFilter represents a key-value pair for label filtering.

type LabelMatcher

type LabelMatcher struct {
	Key   string
	Value string
}

LabelMatcher matches a specific label key=value pair.

func ParseLabelFlag

func ParseLabelFlag(s string) (LabelMatcher, error)

ParseLabelFlag parses a "key=value" label matcher.

type LabelVal

type LabelVal struct {
	Value string `json:"value"`
	Lines int64  `json:"lines"`
	Bytes int64  `json:"bytes"`
}

LabelVal summarizes one label value's contribution.

type MergeProgress added in v0.3.0

type MergeProgress struct {
	FilesCopied int
	TotalFiles  int
}

MergeProgress reports progress during merge.

type Metadata added in v1.0.6

type Metadata struct {
	Version    int                    `json:"version"`
	Format     string                 `json:"format"`
	Started    time.Time              `json:"started"`
	Stopped    time.Time              `json:"stopped"`
	TotalLines int64                  `json:"total_lines"`
	TotalBytes int64                  `json:"total_bytes"`
	LabelsSeen []string               `json:"labels_seen"`
	Redaction  map[string]interface{} `json:"redaction"`
}

Metadata represents the structure of metadata.json

func NewMetadata added in v1.0.6

func NewMetadata() *Metadata

NewMetadata creates a new Metadata instance with default values.

func ReadMetadata added in v1.0.6

func ReadMetadata(dir string) (*Metadata, error)

ReadMetadata reads the metadata.json file from the specified directory.

type Participant added in v1.4.0

type Participant struct {
	Name  string `json:"name"`
	Index int    `json:"index"`
}

Participant represents a service in the sequence diagram.

type RateBucket added in v0.3.0

type RateBucket struct {
	Minute time.Time `json:"minute"`
	RateA  int64     `json:"rate_a"`
	RateB  int64     `json:"rate_b"`
}

RateBucket compares log rates at a given minute.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader provides streaming access to a capture directory.

func NewReader

func NewReader(dir string) (*Reader, error)

NewReader opens a capture directory and resolves its file list.

func (*Reader) Files

func (r *Reader) Files() []FileInfo

Files returns the resolved file list for parallel scanning.

func (*Reader) Metadata

func (r *Reader) Metadata() *recv.Metadata

Metadata returns the capture session metadata.

func (*Reader) Scan

func (r *Reader) Scan(filter *Filter, fn func(recv.LogEntry) bool) (int64, error)

Scan iterates all files in order, applying the filter and calling fn for each matching entry. If fn returns false, scanning stops early. Returns total lines scanned and any error.

func (*Reader) ServiceSummary added in v1.9.2

func (r *Reader) ServiceSummary() []ServiceEntry

ServiceSummary aggregates label values and line counts across all indexed files. It picks the label key with the most distinct values (usually "app" or "container"). Returns nil if no label data is available.

func (*Reader) TotalLines

func (r *Reader) TotalLines() int64

TotalLines returns the sum of lines from all files, including orphans.

type ReplayModel

type ReplayModel struct {
	// contains filtered or unexported fields
}

ReplayModel is the bubbletea model for the capture replay TUI.

func NewReplayModel

func NewReplayModel(feeder *Feeder, ring *recv.LogRing, meta *recv.Metadata, dir string, totalLines int64, services []ServiceEntry) ReplayModel

NewReplayModel creates a replay TUI model. If services has >1 entry, a picker is shown before replay starts.

func (ReplayModel) Init

func (m ReplayModel) Init() tea.Cmd

Init starts the tick timer and the feeder (unless picker is shown first).

func (ReplayModel) Update

func (m ReplayModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages.

func (ReplayModel) View

func (m ReplayModel) View() string

View renders the replay TUI.

type ReportCapture added in v1.1.0

type ReportCapture struct {
	Dir             string    `json:"dir"`
	Files           int       `json:"files"`
	Entries         int64     `json:"entries"`
	Bytes           int64     `json:"bytes"`
	Started         time.Time `json:"started"`
	Stopped         time.Time `json:"stopped,omitempty"`
	DurationSeconds float64   `json:"duration_seconds"`
}

ReportCapture holds capture metadata for the report.

type ReportConfig added in v1.1.0

type ReportConfig struct {
	Jobs int // parallel triage workers
	Top  int // top error signatures
}

ReportConfig controls report generation behavior.

type ReportResult added in v1.1.0

type ReportResult struct {
	Capture   ReportCapture  `json:"capture"`
	Labels    map[string]int `json:"labels"`
	Triage    ReportTriage   `json:"triage"`
	Severity  string         `json:"severity"`
	Suggested []string       `json:"suggested_commands,omitempty"`
}

ReportResult is the single-artifact incident deliverable.

func Report added in v1.1.0

func Report(dir string, cfg ReportConfig, progress func(TriageProgress)) (*ReportResult, error)

Report generates a combined inspect + triage result for a capture directory.

func (*ReportResult) WriteHTML added in v1.1.0

func (r *ReportResult) WriteHTML(w io.Writer, triageResult *TriageResult, meta *recv.Metadata) error

WriteHTML writes a self-contained HTML report. It delegates to the triage HTML writer with an extended header.

func (*ReportResult) WriteJSON added in v1.1.0

func (r *ReportResult) WriteJSON(w io.Writer) error

WriteJSON writes the report as indented JSON.

type ReportTriage added in v1.1.0

type ReportTriage struct {
	TotalLines   int64            `json:"total_lines"`
	ErrorLines   int64            `json:"error_lines"`
	ErrorRatePct float64          `json:"error_rate_pct"`
	TopErrors    []ErrorSignature `json:"top_errors,omitempty"`
	Windows      TriageWindows    `json:"windows"`
}

ReportTriage holds triage results for the report.

type SequenceDiagram added in v1.4.0

type SequenceDiagram struct {
	Participants []Participant `json:"participants"`
	Interactions []Interaction `json:"interactions"`
}

SequenceDiagram holds participants and interactions for ASCII rendering.

func BuildSequence added in v1.4.0

func BuildSequence(correlations []Correlation) *SequenceDiagram

BuildSequence converts correlations into a renderable sequence diagram.

func (*SequenceDiagram) WriteASCII added in v1.4.0

func (s *SequenceDiagram) WriteASCII(w io.Writer)

WriteASCII renders the sequence diagram as ASCII art.

func (*SequenceDiagram) WriteJSON added in v1.4.0

func (s *SequenceDiagram) WriteJSON(w io.Writer) error

WriteJSON writes the sequence diagram as JSON.

type ServiceEntry added in v1.9.2

type ServiceEntry struct {
	Label string
	Value string
	Lines int64
}

ServiceEntry describes one label value and its total line count.

type SignResult added in v1.4.0

type SignResult struct {
	Dir      string       `json:"dir"`
	RootHash string       `json:"root_hash"`
	Files    []FileDigest `json:"files"`
	SignedAt time.Time    `json:"signed_at"`
}

SignResult holds the output of signing a capture directory.

func Sign added in v1.4.0

func Sign(dir string) (*SignResult, error)

Sign computes SHA256 hashes for all files in a capture directory and writes a manifest.sha256 file. Returns the signing result.

func (*SignResult) WriteJSON added in v1.4.0

func (r *SignResult) WriteJSON(w io.Writer) error

WriteJSON writes the sign result as indented JSON.

func (*SignResult) WriteText added in v1.4.0

func (r *SignResult) WriteText(w io.Writer)

WriteText writes a human-readable signing summary.

type SliceOptions added in v1.0.6

type SliceOptions struct {
	From       time.Time
	To         time.Time
	Labels     []LabelFilter
	Grep       *regexp.Regexp
	OutputDir  string
	CaptureDir string
}

SliceOptions holds the parameters for the slicing operation.

type Speed

type Speed float64

Speed controls replay rate. 0 = instant, 1 = realtime, N = fast-forward.

const (
	SpeedInstant  Speed = 0
	SpeedRealtime Speed = 1
)

type Summary

type Summary struct {
	Dir         string                `json:"dir"`
	Meta        *recv.Metadata        `json:"metadata"`
	Files       int                   `json:"files"`
	TotalLines  int64                 `json:"total_lines"`
	TotalBytes  int64                 `json:"total_bytes"`
	DiskSize    int64                 `json:"disk_size"`
	DataFrom    time.Time             `json:"data_from,omitempty"`
	DataTo      time.Time             `json:"data_to,omitempty"`
	LinesPerSec float64               `json:"lines_per_sec,omitempty"`
	BucketWidth string                `json:"bucket_width,omitempty"`
	Labels      map[string][]LabelVal `json:"labels,omitempty"`
	Timeline    []Bucket              `json:"timeline,omitempty"`
}

Summary holds aggregated information about a capture directory.

func Inspect

func Inspect(dir string) (*Summary, error)

Inspect reads metadata.json and index.jsonl from a capture directory and returns an aggregated summary. No decompression is performed.

func (*Summary) WriteJSON

func (s *Summary) WriteJSON(w io.Writer) error

WriteJSON renders the summary as indented JSON.

func (*Summary) WriteText

func (s *Summary) WriteText(w io.Writer)

WriteText renders the summary as human-readable text.

type TalkerEntry

type TalkerEntry struct {
	Value      string `json:"value"`
	TotalLines int64  `json:"total_lines"`
	ErrorLines int64  `json:"error_lines"`
}

TalkerEntry represents volume per label value.

type TimeWindow

type TimeWindow struct {
	From string `json:"from"`
	To   string `json:"to"`
	Desc string `json:"description"`
}

TimeWindow represents a recommended time range.

type TriageBucket

type TriageBucket struct {
	Time       time.Time `json:"time"`
	TotalLines int64     `json:"total_lines"`
	ErrorLines int64     `json:"error_lines"`
}

TriageBucket represents one time window in the histogram.

type TriageConfig

type TriageConfig struct {
	Jobs          int           // parallel workers (default runtime.NumCPU())
	Window        time.Duration // histogram bucket width (default 1m)
	Top           int           // top error signatures (default 50)
	MaxSignatures int           // cap on unique signatures kept in memory (default 10000)
}

TriageConfig controls triage behavior.

type TriageProgress

type TriageProgress struct {
	Scanned int64
	Total   int64
}

TriageProgress reports progress during triage scanning.

type TriageResult

type TriageResult struct {
	Dir          string                   `json:"dir"`
	Meta         *recv.Metadata           `json:"metadata,omitempty"`
	Timeline     []TriageBucket           `json:"timeline,omitempty"`
	Errors       []ErrorSignature         `json:"errors,omitempty"`
	Talkers      map[string][]TalkerEntry `json:"talkers,omitempty"`
	Windows      TriageWindows            `json:"windows"`
	Correlations []Correlation            `json:"correlations,omitempty"`
	TotalLines   int64                    `json:"total_lines"`
	ErrorLines   int64                    `json:"error_lines"`
}

TriageResult holds all triage output data.

func Triage

func Triage(src string, cfg TriageConfig, progress func(TriageProgress)) (*TriageResult, error)

Triage scans a capture directory for anomalies and produces a summary report.

func (*TriageResult) WriteHTML added in v1.0.0

func (r *TriageResult) WriteHTML(w io.Writer) error

WriteHTML writes a self-contained HTML triage report.

func (*TriageResult) WriteJSON added in v0.3.0

func (r *TriageResult) WriteJSON(w io.Writer) error

WriteJSON writes the full triage result as JSON.

func (*TriageResult) WriteSequence added in v1.4.0

func (r *TriageResult) WriteSequence(w io.Writer)

WriteSequence writes an ASCII sequence diagram of cross-service correlations.

func (*TriageResult) WriteSummary

func (r *TriageResult) WriteSummary(w io.Writer)

WriteSummary writes a human-readable triage report.

func (*TriageResult) WriteTimeline

func (r *TriageResult) WriteTimeline(w io.Writer)

WriteTimeline writes a CSV histogram: minute,total_lines,error_lines.

func (*TriageResult) WriteTopErrors

func (r *TriageResult) WriteTopErrors(w io.Writer)

WriteTopErrors writes ranked error signatures.

func (*TriageResult) WriteTopTalkers

func (r *TriageResult) WriteTopTalkers(w io.Writer)

WriteTopTalkers writes volume per label value, sorted by line count.

func (*TriageResult) WriteWindows

func (r *TriageResult) WriteWindows(w io.Writer) error

WriteWindows writes recommended time windows as JSON.

type TriageWindows

type TriageWindows struct {
	PeakError     *TimeWindow `json:"peak_error,omitempty"`
	IncidentStart *TimeWindow `json:"incident_start,omitempty"`
	SteadyState   *TimeWindow `json:"steady_state,omitempty"`
}

TriageWindows holds recommended time windows for slicing.

type VerifyResult added in v1.4.0

type VerifyResult struct {
	Dir        string         `json:"dir"`
	RootHash   string         `json:"root_hash"`
	Valid      bool           `json:"valid"`
	Mismatches []FileMismatch `json:"mismatches,omitempty"`
	Missing    []string       `json:"missing,omitempty"`
	Extra      []string       `json:"extra,omitempty"`
}

VerifyResult holds the output of verifying a signed capture.

func Verify added in v1.4.0

func Verify(dir string) (*VerifyResult, error)

Verify checks the integrity of a signed capture directory against its manifest.

func (*VerifyResult) WriteJSON added in v1.4.0

func (r *VerifyResult) WriteJSON(w io.Writer) error

WriteJSON writes the verify result as indented JSON.

func (*VerifyResult) WriteText added in v1.4.0

func (r *VerifyResult) WriteText(w io.Writer)

WriteText writes a human-readable verification summary.

Jump to

Keyboard shortcuts

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