runtrace

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SchemaVersion            = 5
	DefaultLifecycleCapacity = 256
	DefaultSampleInterval    = 250 * time.Millisecond
)

Variables

View Source
var (
	ErrInvalidTarget             = errors.New("trace target is invalid")
	ErrInvalidConfig             = errors.New("trace configuration is invalid")
	ErrRunIDUnavailable          = errors.New("trace run identity is unavailable")
	ErrTraceDirectoryUnavailable = errors.New("trace directory is unavailable")
	ErrTraceFileUnavailable      = errors.New("trace file is unavailable")
	ErrTraceNameUnavailable      = errors.New("trace filename is unavailable")
	ErrTraceExists               = errors.New("trace path already exists")
)

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
}

type Config

type Config struct {
	LifecycleCapacity int
	SampleInterval    time.Duration
}

type Dependencies

type Dependencies struct {
	Clock           Clock
	Random          io.Reader
	EnsureDirectory EnsureDirectory
	OpenFile        OpenFile
	NewTicker       NewTicker
}

type EnsureDirectory

type EnsureDirectory func(path string) error

type NewTicker

type NewTicker func(interval time.Duration) Ticker

type OpenFile

type OpenFile func(path string) (TraceFile, error)

OpenFile is an exclusive-create seam: collisions must remain distinguishable so directory targets can choose a new identity without inspecting existing evidence.

type Recorder

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

func Open

func Open(target Target, command clievent.Command, config Config) (*Recorder, error)

func OpenWithDependencies

func OpenWithDependencies(
	target Target,
	command clievent.Command,
	config Config,
	dependencies Dependencies,
) (*Recorder, error)

func (*Recorder) Close

func (recorder *Recorder) Close() Status

func (*Recorder) Health

func (recorder *Recorder) Health() <-chan clievent.TraceIncomplete

Health exposes a capacity-one edge notification. The final Close status is authoritative because later failures and final drop totals may follow this signal.

func (*Recorder) Path

func (recorder *Recorder) Path() string

Path is intentionally local recorder state; trace rows omit it so a diagnostic artifact cannot disclose the caller's filesystem namespace.

func (*Recorder) Record

func (recorder *Recorder) Record(event clievent.Event) (accepted bool)

Record never performs file IO and never waits for queue capacity. A false result means the event was rejected or could not be retained.

func (*Recorder) ReportRejectionEvidenceLoss

func (recorder *Recorder) ReportRejectionEvidenceLoss(count uint64) bool

This numeric path cannot recurse through the rejected observation contract.

func (*Recorder) ReportUpstreamLoss

func (recorder *Recorder) ReportUpstreamLoss(loss clievent.TraceLoss) bool

ReportUpstreamLoss preserves loss that happened before an event reached the recorder. Progress sampling loss alone is expected and does not make a trace incomplete.

func (*Recorder) RunID

func (recorder *Recorder) RunID() string

func (*Recorder) Status

func (recorder *Recorder) Status() Status

type RunTraceRecord

type RunTraceRecord struct {
	SourceTime    string             `json:"source_time,omitempty"`
	Scope         *diagnostics.Scope `json:"scope,omitempty"`
	SchemaVersion int                `json:"schema_version"`
	Sequence      string             `json:"sequence"`
	Time          string             `json:"time"`
	ElapsedMS     string             `json:"elapsed_ms"`
	Level         string             `json:"level"`
	Event         string             `json:"event"`
	Command       string             `json:"command"`
	RuntimeRunID  string             `json:"runtime_run_id"`
	Correlation   any                `json:"correlation,omitempty"`
	Payload       any                `json:"payload"`
}

RunTraceRecord combines product events and source-owned diagnostics for export. Scope distinguishes diagnostic records; their names and payloads are open. The trace envelope version is independent of the typed product wire contract.

type Status

type Status struct {
	RejectionEvidenceDropped uint64
	ContractRejected         uint64
	Complete                 bool
	LifecycleDropped         uint64
	ProgressDropped          uint64
	EventsWritten            uint64
	WriterFailed             bool
	FlushFailed              bool
	SchemaLimited            bool
}

type Target

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

Target keeps the no-clobber policy coupled to the namespace the user chose. Its fields stay private so callers cannot create an ambiguous file-or-directory target.

func ExactFile

func ExactFile(path string) (Target, error)

ExactFile treats the caller's path as a one-attempt ownership claim so a collision cannot alter the prior run's evidence.

func RunDirectory

func RunDirectory(path string) (Target, error)

RunDirectory preserves prior evidence by assigning each invocation a fresh, internally generated sibling rather than applying overwrite or rotation policy.

type Ticker

type Ticker interface {
	C() <-chan time.Time
	Stop()
}

type TraceFile

type TraceFile interface {
	io.Writer
	Rollback(offset int64) error
	Flush() error
	Close() error
}

Jump to

Keyboard shortcuts

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