idtui

package
v0.12.6 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: Apache-2.0 Imports: 32 Imported by: 1

Documentation

Index

Constants

View Source
const (
	HideCompletedVerbosity    = 0
	ShowCompletedVerbosity    = 1
	ExpandCompletedVerbosity  = 2
	ShowInternalVerbosity     = 3
	ShowEncapsulatedVerbosity = 3
	ShowSpammyVerbosity       = 4
	ShowDigestsVerbosity      = 4
)
View Source
const (
	Block               = "█"
	CaretDownEmpty      = "▽"
	CaretDownFilled     = "▼"
	CaretLeftFilled     = "◀" // "<"
	CaretRightEmpty     = "▷" // ">"
	CaretRightFilled    = "▶" // ">"
	CornerBottomLeft    = "╰"
	CornerBottomRight   = "╯"
	CornerTopLeft       = "╭"
	CornerTopRight      = "╮"
	CrossBar            = "┼"
	DotEmpty            = "○"
	DotFilled           = "●"
	HorizBar            = "─"
	HorizBottomBar      = "┬"
	HorizHalfLeftBar    = "╴"
	HorizHalfRightBar   = "╶"
	HorizTopBar         = "┴"
	HorizTopBoldBar     = "┻"
	InactiveGroupSymbol = VertBar
	TaskSymbol          = VertRightBoldBar
	VertBar             = "│"
	VertBoldBar         = "┃"
	VertDottedBar       = "┊" // ┊┆┇┋╎
	VertLeftBar         = "┤"
	VertLeftBoldBar     = "┫"
	VertRightBar        = "├"
	VertRightBoldBar    = "┣"
	IconSkipped         = "∅"
	IconSuccess         = "✔"
	IconFailure         = "✘"
)

Variables

Functions

func ColorProfile added in v0.11.1

func ColorProfile() termenv.Profile

ColorProfile returns Ascii if, and only if, NO_COLOR or similar is set. Otherwise it returns termenv.ANSI, allowing colors to be used.

Note that color profiles beyond simple ANSI are not used by Progrock. 16 colors is all you need. Anything else disrespects the user's color scheme preferences.

func NewOutput added in v0.11.1

func NewOutput(w io.Writer, opts ...termenv.OutputOption) *termenv.Output

NewOutput returns a termenv.Output that will always use color, regardless of whether w is a TTY, unless NO_COLOR is explicitly set.

Progrock is opinionated here. Termenv disables colors by default if stdout is not a TTY or if the CI env var is set. We don't want that, because folks deserve colorful output in CI too.

To disable colors, set NO_COLOR (https://no-color.org/).

Types

type DB added in v0.9.9

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

	Traces        map[trace.TraceID]*Trace
	Spans         map[trace.SpanID]*Span
	SpanOrder     []*Span
	Children      map[trace.SpanID]map[trace.SpanID]struct{}
	ChildrenOrder map[trace.SpanID][]trace.SpanID

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

	Effects    map[string]*Span
	EffectSite map[string]*Span
}

func NewDB added in v0.9.9

func NewDB() *DB

func (*DB) AllTraces added in v0.11.0

func (db *DB) AllTraces() []*Trace

func (*DB) Close added in v0.9.9

func (*DB) Close() error

func (*DB) CollectTree added in v0.12.0

func (db *DB) CollectTree(spans []*Span) []*TraceTree

func (*DB) ExportSpans added in v0.11.0

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

func (*DB) ForceFlush added in v0.11.7

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

func (*DB) HighLevelSpan added in v0.11.0

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

func (*DB) LogExporter added in v0.11.7

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

func (*DB) MostInterestingSpan added in v0.11.0

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

func (*DB) MustCall added in v0.11.0

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

func (*DB) RowsView added in v0.12.0

func (db *DB) RowsView(zoomedID trace.SpanID) *RowsView

func (*DB) SetPrimarySpan added in v0.11.0

func (db *DB) SetPrimarySpan(span trace.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 added in v0.11.0

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

func (*DB) Simplify added in v0.9.9

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

func (*DB) WalkSpans added in v0.12.0

func (db *DB) WalkSpans(spans []*Span, f func(*TraceTree))

type DBLogExporter added in v0.11.7

type DBLogExporter struct {
	*DB
}

func (DBLogExporter) Export added in v0.11.7

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

type Dump added in v0.12.0

type Dump struct {
	Newline string
	Prefix  string
}

func (*Dump) DumpID added in v0.12.0

func (d *Dump) DumpID(out *termenv.Output, id *call.ID) error

type Frontend

type Frontend interface {
	// Run starts a frontend, and runs the target function.
	Run(ctx context.Context, opts FrontendOpts, f func(context.Context) error) error

	// SetPrimary tells the frontend which span should be treated like the focal
	// point of the command. Its output will be displayed at the end, and its
	// children will be promoted to the "top-level" of the TUI.
	SetPrimary(spanID trace.SpanID)
	Background(cmd tea.ExecCommand) error
	// RevealAllSpans tells the frontend to show all spans, not just the spans
	// beneath the primary span.
	SetRevealAllSpans(bool)

	// Can consume otel spans and logs.
	SpanExporter() sdktrace.SpanExporter
	LogExporter() sdklog.Exporter

	// ConnectedToEngine is called when the CLI connects to an engine.
	ConnectedToEngine(ctx context.Context, name string, version string, clientID string)
	// SetCloudURL is called after the CLI checks auth and sets the cloud URL.
	SetCloudURL(ctx context.Context, url string, msg string, logged bool)
}

func New

func New() Frontend

func NewPlain added in v0.11.5

func NewPlain() Frontend

type FrontendOpts added in v0.11.5

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

	// RevealAllSpans tells the frontend to show all spans, not just the spans
	// beneath the primary span.
	RevealAllSpans bool
}

func (FrontendOpts) ShouldShow added in v0.12.0

func (opts FrontendOpts) ShouldShow(tree *TraceTree) bool

type FrontendSpanExporter added in v0.11.7

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

func (FrontendSpanExporter) Background added in v0.11.7

func (fe FrontendSpanExporter) Background(cmd tea.ExecCommand) error

func (FrontendSpanExporter) Close added in v0.11.7

func (fe FrontendSpanExporter) Close() error

func (FrontendSpanExporter) ConnectedToEngine added in v0.11.7

func (fe FrontendSpanExporter) ConnectedToEngine(ctx context.Context, name string, version string, clientID string)

func (FrontendSpanExporter) ExportSpans added in v0.11.7

func (fe FrontendSpanExporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpan) error

func (FrontendSpanExporter) ForceFlush added in v0.11.7

func (fe FrontendSpanExporter) ForceFlush(context.Context) error

func (FrontendSpanExporter) Init added in v0.11.7

func (fe FrontendSpanExporter) Init() tea.Cmd

func (FrontendSpanExporter) LogExporter added in v0.11.7

func (fe FrontendSpanExporter) LogExporter() sdklog.Exporter

func (FrontendSpanExporter) Render added in v0.11.7

func (fe FrontendSpanExporter) Render(out *termenv.Output) error

func (FrontendSpanExporter) Run added in v0.11.7

func (fe FrontendSpanExporter) Run(ctx context.Context, opts FrontendOpts, run func(context.Context) error) error

Run starts the TUI, calls the run function, stops the TUI, and finally prints the primary output to the appropriate stdout/stderr streams.

func (FrontendSpanExporter) SetCloudURL added in v0.12.0

func (fe FrontendSpanExporter) SetCloudURL(ctx context.Context, url string, msg string, logged bool)

func (FrontendSpanExporter) SetPrimary added in v0.11.7

func (fe FrontendSpanExporter) SetPrimary(spanID trace.SpanID)

func (FrontendSpanExporter) SetRevealAllSpans added in v0.12.5

func (fe FrontendSpanExporter) SetRevealAllSpans(val bool)

func (FrontendSpanExporter) Shutdown added in v0.11.7

func (fe FrontendSpanExporter) Shutdown(ctx context.Context) error

func (FrontendSpanExporter) SpanExporter added in v0.11.7

func (fe FrontendSpanExporter) SpanExporter() sdktrace.SpanExporter

func (FrontendSpanExporter) Update added in v0.11.7

func (fe FrontendSpanExporter) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (FrontendSpanExporter) View added in v0.11.7

func (fe FrontendSpanExporter) View() string

type Rows added in v0.12.0

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

type RowsView added in v0.11.7

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

func (*RowsView) Rows added in v0.12.0

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

type Span added in v0.9.9

type Span struct {
	sdktrace.ReadOnlySpan

	ParentSpan *Span
	ChildSpans []*Span

	ID trace.SpanID

	IsSelfRunning bool

	Digest string
	Call   *callpbv1.Call
	Base   *callpbv1.Call

	Internal bool
	Cached   bool
	Canceled bool
	EffectID string

	Inputs         []string
	Effects        []string
	RunningEffects map[string]*Span
	FailedEffects  map[string]*Span

	Encapsulate  bool
	Encapsulated bool
	Mask         bool
	Passthrough  bool
	Ignore       bool
	// contains filtered or unexported fields
}

func (*Span) ActiveDuration added in v0.12.0

func (span *Span) ActiveDuration(fallbackEnd time.Time) time.Duration

func (*Span) Bar added in v0.9.9

func (span *Span) Bar() SpanBar

func (*Span) ChildrenAndEffects added in v0.12.0

func (span *Span) ChildrenAndEffects() []*Span

func (*Span) Classes added in v0.11.0

func (span *Span) Classes() string

func (*Span) EffectSpans added in v0.12.0

func (span *Span) EffectSpans() []*Span

func (*Span) EndTime added in v0.11.0

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

func (*Span) EndTimeOrFallback added in v0.12.0

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

func (*Span) Err added in v0.11.0

func (span *Span) Err() error

func (*Span) Failed added in v0.12.0

func (span *Span) Failed() bool

func (*Span) HasParent added in v0.12.0

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

func (*Span) IsBefore added in v0.11.0

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

func (*Span) IsInternal added in v0.11.0

func (span *Span) IsInternal() bool

func (*Span) IsRunning added in v0.11.0

func (span *Span) IsRunning() bool

func (*Span) Name added in v0.11.0

func (span *Span) Name() string

func (*Span) SelfDuration added in v0.12.0

func (span *Span) SelfDuration(fallbackEnd time.Time) time.Duration

type SpanActivity added in v0.12.0

type SpanActivity struct {
	Duration time.Duration
	Min      time.Time
	Max      time.Time
}

type SpanBar added in v0.11.0

type SpanBar struct {
	Span          *Span
	Duration      time.Duration
	OffsetPercent float64
	WidthPercent  float64
}

func (SpanBar) Render added in v0.11.0

func (bar SpanBar) Render() templ.Component

type Task added in v0.11.0

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

type Trace added in v0.11.0

type Trace struct {
	ID         trace.TraceID
	Epoch, End time.Time
	IsRunning  bool
	// contains filtered or unexported fields
}

func (*Trace) HexID added in v0.11.0

func (trace *Trace) HexID() string

type TraceRow added in v0.9.9

type TraceRow struct {
	Index                   int
	Span                    *Span
	Depth                   int
	IsRunningOrChildRunning 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 added in v0.12.0

type TraceTree struct {
	Span *Span

	Parent *TraceTree

	IsRunningOrChildRunning bool
	Chained                 bool

	Children []*TraceTree
}

func (*TraceTree) Depth added in v0.12.0

func (row *TraceTree) Depth() int

type Vterm added in v0.9.9

type Vterm struct {
	Offset int
	Height int
	Width  int

	Prefix string
	// contains filtered or unexported fields
}

func NewVterm added in v0.9.9

func NewVterm() *Vterm

func (*Vterm) Init added in v0.9.9

func (term *Vterm) Init() tea.Cmd

func (*Vterm) LastLine added in v0.9.9

func (term *Vterm) LastLine() string

LastLine returns the last line of visible text, with ANSI formatting, but without any trailing whitespace.

func (*Vterm) Print added in v0.9.9

func (term *Vterm) Print(w io.Writer) error

Print prints the full log output without any formatting.

func (*Vterm) Render added in v0.9.9

func (term *Vterm) Render(w io.Writer, offset, height int)

Bytes returns the output for the given region of the terminal, with ANSI formatting.

func (*Vterm) ScrollPercent added in v0.9.9

func (term *Vterm) ScrollPercent() float64

func (*Vterm) SetHeight added in v0.9.9

func (term *Vterm) SetHeight(height int)

func (*Vterm) SetPrefix added in v0.9.9

func (term *Vterm) SetPrefix(prefix string)

func (*Vterm) SetWidth added in v0.9.9

func (term *Vterm) SetWidth(width int)

func (*Vterm) Term added in v0.9.9

func (term *Vterm) Term() *midterm.Terminal

func (*Vterm) Update added in v0.9.9

func (term *Vterm) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Vterm) UsedHeight added in v0.9.9

func (term *Vterm) UsedHeight() int

func (*Vterm) View added in v0.9.9

func (term *Vterm) View() string

View returns the output for the current region of the terminal, with ANSI formatting.

func (*Vterm) Write added in v0.9.9

func (term *Vterm) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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