dagui

package
v0.17.0-llm.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2025 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	HideCompletedVerbosity    = 0
	ShowCompletedVerbosity    = 1
	ExpandCompletedVerbosity  = 2
	ShowInternalVerbosity     = 3
	ShowEncapsulatedVerbosity = 3
	ShowSpammyVerbosity       = 4
	ShowDigestsVerbosity      = 4
	ShowMetricsVerbosity      = 3
)

Variables

This section is empty.

Functions

func FormatDuration

func FormatDuration(d time.Duration) string

func ShouldSkipFunction added in v0.15.4

func ShouldSkipFunction(obj, field string) bool

func WalkTree added in v0.15.0

func WalkTree(tree []*TraceTree, f func(*TraceTree, int) WalkDecision)

Types

type Activity added in v0.15.0

type Activity struct {
	CompletedIntervals []Interval
	EarliestRunning    time.Time

	// Keep track of the full set of running spans so we can update
	// EarliestRunning as they complete.
	//
	// This needs to be synced to the frontend so it doesn't lose track of the
	// running status in updateEarliest. We exclude from JSON marshalling since
	// the map key is incompatible. Syncing to the frontend uses encoding/gob,
	// which accepts the map key type.
	AllRunning map[SpanID]time.Time `json:"-"`
}

func (*Activity) Add added in v0.15.0

func (activity *Activity) Add(span *Span) bool

func (*Activity) Duration added in v0.15.0

func (activity *Activity) Duration(now time.Time) time.Duration

func (*Activity) EndTimeOrFallback added in v0.15.0

func (activity *Activity) EndTimeOrFallback(now time.Time) time.Time

func (*Activity) Intervals added in v0.15.0

func (activity *Activity) Intervals(now time.Time) iter.Seq[Interval]

func (*Activity) IsRunning added in v0.15.0

func (activity *Activity) IsRunning() bool

type DB

type DB struct {
	PrimarySpan SpanID
	PrimaryLogs map[SpanID][]sdklog.Record

	Epoch, End time.Time

	Spans    *OrderedSet[SpanID, *Span]
	RootSpan *Span

	Resources map[attribute.Distinct]*resource.Resource

	CallPayloads map[string]string
	Calls        map[string]*callpbv1.Call

	Outputs   map[string]map[string]struct{}
	OutputOf  map[string]map[string]struct{}
	Intervals map[string]map[time.Time]*Span

	CauseSpans  map[string]SpanSet
	EffectSpans map[string]SpanSet

	CompletedEffects map[string]bool
	FailedEffects    map[string]bool

	// Map of call digest -> metric name -> data points
	// NOTE: this is hard coded for Gauge int64 metricdata essentially right now,
	// needs generalization as more metric types get added
	MetricsByCall map[string]map[string][]metricdata.DataPoint[int64]
	// contains filtered or unexported fields
}

func NewDB

func NewDB() *DB

func (*DB) Aggregation added in v0.13.6

func (db *DB) Aggregation(sdkmetric.InstrumentKind) sdkmetric.Aggregation

func (*DB) AllSpans added in v0.16.2

func (db *DB) AllSpans() iter.Seq[*Span]

func (*DB) Call added in v0.16.2

func (db *DB) Call(dig string) *callpbv1.Call

func (*DB) Close

func (*DB) Close() error

func (*DB) CollectErrors added in v0.15.0

func (db *DB) CollectErrors(rows *RowsView) []*TraceTree

func (*DB) ExportSpans

func (db *DB) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error

func (*DB) FindResource added in v0.15.0

func (db *DB) FindResource(filter attribute.KeyValue) *resource.Resource

func (*DB) ForceFlush

func (db *DB) ForceFlush(ctx context.Context) error

func (*DB) HighLevelSpan

func (db *DB) HighLevelSpan(call *callpbv1.Call) *Span

func (*DB) ImportSnapshots added in v0.15.0

func (db *DB) ImportSnapshots(snapshots []SpanSnapshot)

func (*DB) LogExporter

func (db *DB) LogExporter() sdklog.Exporter

func (*DB) MetricExporter added in v0.13.6

func (db *DB) MetricExporter() sdkmetric.Exporter

func (*DB) MostInterestingSpan

func (db *DB) MostInterestingSpan(dig string) *Span

func (*DB) MustCall

func (db *DB) MustCall(dig string) *callpbv1.Call

func (*DB) RemainingSnapshots added in v0.15.0

func (db *DB) RemainingSnapshots() []SpanSnapshot

func (*DB) RowsView

func (db *DB) RowsView(opts FrontendOpts) *RowsView

func (*DB) SetPrimarySpan

func (db *DB) SetPrimarySpan(span SpanID)

SetPrimarySpan allows the primary span to be explicitly set to a particular span. normally we assume the root span is the primary span, but in a nested scenario we never actually see the root span, so the CLI explicitly sets it to the span it created.

func (*DB) Shutdown

func (db *DB) Shutdown(ctx context.Context) error

func (*DB) Simplify

func (db *DB) Simplify(call *callpbv1.Call, force bool) (smallest *callpbv1.Call)

func (*DB) SpanSnapshots added in v0.15.0

func (db *DB) SpanSnapshots(id SpanID) []SpanSnapshot

func (*DB) Temporality added in v0.13.6

func (*DB) UpdatedSnapshots added in v0.15.0

func (db *DB) UpdatedSnapshots(filter map[SpanID]bool) []SpanSnapshot

func (*DB) WalkSpans

func (db *DB) WalkSpans(opts FrontendOpts, spans iter.Seq[*Span], f func(*TraceTree))

func (*DB) WriteDot added in v0.13.4

func (db *DB) WriteDot(
	outputFilePath string,
	focusField string,
	showInternal bool,
)

type DBLogExporter

type DBLogExporter struct {
	*DB
}

func (DBLogExporter) Export

func (db DBLogExporter) Export(ctx context.Context, logs []sdklog.Record) error

type DBMetricExporter added in v0.13.6

type DBMetricExporter struct {
	*DB
}

func (DBMetricExporter) Export added in v0.13.6

func (db DBMetricExporter) Export(ctx context.Context, resourceMetrics *metricdata.ResourceMetrics) error

type FrontendOpts

type FrontendOpts struct {
	// Debug tells the frontend to show everything and do one big final render.
	Debug bool

	// Silent tells the frontend to not display progress at all.
	Silent bool

	// Verbosity is the level of detail to show in the TUI.
	Verbosity int

	// Don't show things that completed beneath this duration. (default 100ms)
	TooFastThreshold time.Duration

	// Remove completed things after this duration. (default 1s)
	GCThreshold time.Duration

	// Open web browser with the trace URL as soon as pipeline starts.
	OpenWeb bool

	// Leave the TUI running instead of exiting after completion.
	NoExit bool

	// Run a custom function on exit.
	CustomExit func()

	// DotOutputFilePath is the path to write the DOT output to after execution, if any
	DotOutputFilePath string

	// DotFocusField is the field name to focus on in the DOT output, if any
	DotFocusField string

	// DotShowInternal indicates whether to include internal steps in the DOT output
	DotShowInternal bool

	// ZoomedSpan configures a span to be zoomed in on, revealing
	// its child spans.
	ZoomedSpan SpanID

	// FocusedSpan is the currently selected span, i.e. the cursor position.
	FocusedSpan SpanID

	// SpanVerbosity tracks per-span verbosity.
	SpanVerbosity map[SpanID]int

	// Filter is applied while constructing the tree.
	Filter func(*Span) WalkDecision
}

func (FrontendOpts) ShouldShow

func (opts FrontendOpts) ShouldShow(db *DB, span *Span) bool

type Interval added in v0.15.0

type Interval struct {
	Start time.Time
	End   time.Time
}

type OrderedSet added in v0.15.0

type OrderedSet[K, V comparable] struct {
	Order    []V
	KeyFunc  func(V) K
	LessFunc func(V, V) bool
	Map      map[K]V
}

func NewOrderedSet added in v0.15.0

func NewOrderedSet[K comparable, V comparable](keyFunc func(V) K, vs ...V) *OrderedSet[K, V]

func NewSet added in v0.15.0

func NewSet[T comparable]() *OrderedSet[T, T]

func NewSpanSet added in v0.15.0

func NewSpanSet(spans ...*Span) *OrderedSet[SpanID, *Span]

func (*OrderedSet[K, V]) Add added in v0.15.0

func (set *OrderedSet[K, V]) Add(value V) bool

func (*OrderedSet[K, V]) Clear added in v0.15.0

func (set *OrderedSet[K, V]) Clear()

func (*OrderedSet[K, V]) Iter added in v0.16.2

func (set *OrderedSet[K, V]) Iter() iter.Seq[V]

func (*OrderedSet[K, V]) MarshalJSON added in v0.15.0

func (set *OrderedSet[K, V]) MarshalJSON() ([]byte, error)

func (*OrderedSet[K, V]) Remove added in v0.15.0

func (set *OrderedSet[K, V]) Remove(value V) bool

func (*OrderedSet[K, V]) UnmarshalJSON added in v0.15.0

func (set *OrderedSet[K, V]) UnmarshalJSON(p []byte) error

type Rows

type Rows struct {
	Order  []*TraceRow
	BySpan map[SpanID]*TraceRow
}

type RowsView

type RowsView struct {
	Zoomed *Span
	Body   []*TraceTree
	BySpan map[SpanID]*TraceTree
}

func (*RowsView) Rows

func (lv *RowsView) Rows(opts FrontendOpts) *Rows

type Span

type Span struct {
	SpanSnapshot

	ParentSpan    *Span   `json:"-"`
	ChildSpans    SpanSet `json:"-"`
	RunningSpans  SpanSet `json:"-"`
	FailedLinks   SpanSet `json:"-"`
	RevealedSpans SpanSet `json:"-"`

	// Indicates that this span was actually exported to the database, and not
	// just allocated due to a span parent or other relationship.
	Received bool
	// contains filtered or unexported fields
}

func (*Span) Base

func (span *Span) Base() *callpbv1.Call

func (*Span) Before added in v0.15.0

func (span *Span) Before(other *Span) bool

func (*Span) CachedReason added in v0.15.0

func (span *Span) CachedReason() (bool, []string)

func (*Span) Call

func (span *Span) Call() *callpbv1.Call

func (*Span) CanceledReason added in v0.15.0

func (span *Span) CanceledReason() (bool, []string)

func (*Span) CausalSpans added in v0.15.0

func (span *Span) CausalSpans(f func(*Span) bool)

CausalSpans iterates over the spans that directly cause this span, by following links (for newer engines) or attributes (for old engines).

func (*Span) Classes

func (span *Span) Classes() []string

func (*Span) EffectSpans

func (span *Span) EffectSpans(f func(*Span) bool)

func (*Span) EndTimeOrFallback

func (span *Span) EndTimeOrFallback(fallbackEnd time.Time) time.Time

func (*Span) EndTimeOrNow added in v0.15.0

func (span *Span) EndTimeOrNow() time.Time

func (*Span) Errors added in v0.15.0

func (span *Span) Errors() SpanSet

Errors returns the individual errored spans contributing to the span's Failed or CausedFailure status.

func (*Span) FailedReason added in v0.15.0

func (span *Span) FailedReason() (bool, []string)

func (*Span) HasParent

func (span *Span) HasParent(parent *Span) bool

func (*Span) Hidden added in v0.15.0

func (span *Span) Hidden(opts FrontendOpts) bool

func (*Span) IsCached added in v0.15.0

func (span *Span) IsCached() bool

func (*Span) IsCanceled added in v0.15.0

func (span *Span) IsCanceled() bool

func (*Span) IsFailed added in v0.15.0

func (span *Span) IsFailed() bool

func (*Span) IsFailedOrCausedFailure added in v0.15.0

func (span *Span) IsFailedOrCausedFailure() bool

func (*Span) IsInternal

func (span *Span) IsInternal() bool

func (*Span) IsOK added in v0.15.0

func (span *Span) IsOK() bool

func (*Span) IsPending added in v0.15.0

func (span *Span) IsPending() bool

func (*Span) IsRunning

func (span *Span) IsRunning() bool

func (*Span) IsRunningOrEffectsRunning added in v0.15.0

func (span *Span) IsRunningOrEffectsRunning() bool

func (*Span) IsUnset added in v0.15.0

func (span *Span) IsUnset() bool

func (*Span) Matches added in v0.15.0

func (span *Span) Matches(match func(*Span) bool) bool

Matches returns true if the span matches the filter, looking through Passthrough span parents until a match is found or a non-Passthrough span is reached.

func (*Span) Parents added in v0.15.0

func (span *Span) Parents(f func(*Span) bool)

func (*Span) PendingReason added in v0.15.0

func (span *Span) PendingReason() (bool, []string)
func (span *Span) PropagateStatusToParentsAndLinks()

PropagateStatusToParentsAndLinks updates the running and failed state of all parent spans, linked spans, and their parents to reflect the span.

NOTE: failed state only propagates to spans that installed the current span's effect - it does _not_ propagate through the parent span.

func (*Span) Snapshot added in v0.15.0

func (span *Span) Snapshot() SpanSnapshot

Snapshot returns a snapshot of the span's current state.

func (*Span) VisibleParent added in v0.15.0

func (span *Span) VisibleParent(opts FrontendOpts) *Span

type SpanContext added in v0.15.0

type SpanContext struct {
	TraceID TraceID
	SpanID  SpanID
}

type SpanID added in v0.15.0

type SpanID struct {
	trace.SpanID
}

func (SpanID) MarshalJSON added in v0.15.0

func (id SpanID) MarshalJSON() ([]byte, error)

func (*SpanID) UnmarshalJSON added in v0.15.0

func (id *SpanID) UnmarshalJSON(data []byte) error

type SpanSet added in v0.15.0

type SpanSet = *OrderedSet[SpanID, *Span]

type SpanSnapshot added in v0.15.0

type SpanSnapshot struct {
	// Monotonically increasing number for each update seen for this span.
	Version int

	// Indicates that this snapshot is in its final state and should be trusted
	// over any state derived from the local state.
	// This is used for snapshots that come from a remote server.
	Final bool

	ID        SpanID
	Name      string
	StartTime time.Time
	EndTime   time.Time

	Activity Activity `json:",omitempty"`

	ParentID SpanID        `json:",omitempty"`
	Links    []SpanContext `json:",omitempty"`

	Status sdktrace.Status `json:",omitempty"`

	// statuses derived from span and its effects
	Failed_         bool     `json:",omitempty"`
	FailedReason_   []string `json:",omitempty"`
	Cached_         bool     `json:",omitempty"`
	CachedReason_   []string `json:",omitempty"`
	Pending_        bool     `json:",omitempty"`
	PendingReason_  []string `json:",omitempty"`
	Canceled_       bool     `json:",omitempty"`
	CanceledReason_ []string `json:",omitempty"`

	// statuses reported by the span via attributes
	Canceled bool `json:",omitempty"`
	Cached   bool `json:",omitempty"`

	// UI preferences reported by the span, or applied to it (sync=>passthrough)
	Internal     bool   `json:",omitempty"`
	Encapsulate  bool   `json:",omitempty"`
	Encapsulated bool   `json:",omitempty"`
	Passthrough  bool   `json:",omitempty"`
	Ignore       bool   `json:",omitempty"`
	Reveal       bool   `json:",omitempty"`
	ActorEmoji   string `json:",omitempty"`
	Message      string `json:",omitempty"`

	Inputs []string `json:",omitempty"`
	Output string   `json:",omitempty"`

	EffectID         string   `json:",omitempty"`
	EffectIDs        []string `json:",omitempty"`
	EffectsCompleted []string `json:",omitempty"`

	CallDigest  string `json:",omitempty"`
	CallPayload string `json:",omitempty"`

	ChildCount int  `json:",omitempty"`
	HasLogs    bool `json:",omitempty"`
}

func (*SpanSnapshot) ProcessAttribute added in v0.15.0

func (snapshot *SpanSnapshot) ProcessAttribute(name string, val any)

type Task

type Task struct {
	Span      sdktrace.ReadOnlySpan
	Name      string
	Current   int64
	Total     int64
	Started   time.Time
	Completed time.Time
}

type TraceID added in v0.15.0

type TraceID struct {
	trace.TraceID
}

func (TraceID) MarshalJSON added in v0.15.0

func (id TraceID) MarshalJSON() ([]byte, error)

func (*TraceID) UnmarshalJSON added in v0.15.0

func (id *TraceID) UnmarshalJSON(data []byte) error

type TraceRow

type TraceRow struct {
	Index                   int
	Span                    *Span
	Chained                 bool
	Depth                   int
	IsRunningOrChildRunning bool
	Previous                *TraceRow
	Parent                  *Span
	HasChildren             bool
}

TraceRow is the flattened representation of the tree so we can easily walk it backwards and render only the parts that will fit on screen. Otherwise large traces get giga slow.

type TraceTree

type TraceTree struct {
	Span *Span

	Parent *TraceTree

	IsRunningOrChildRunning bool
	Chained                 bool
	Final                   bool
	RevealedChildren        bool

	Children []*TraceTree
}

func (*TraceTree) Depth

func (row *TraceTree) Depth() int

type WalkDecision added in v0.16.2

type WalkDecision int
const (
	WalkContinue WalkDecision = iota
	WalkSkip
	WalkPassthrough
	WalkStop
)

Jump to

Keyboard shortcuts

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