idtui

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TooFastThreshold = 100 * time.Millisecond
	GCThreshold      = 1 * time.Second
)

Variables

This section is empty.

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/).

func WalkSteps added in v0.9.9

func WalkSteps(spans []*Span, f func(*TraceRow))

Types

type DB added in v0.9.9

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

	Logs        map[trace.SpanID]*Vterm
	LogWidth    int
	PrimarySpan trace.SpanID
	PrimaryLogs map[trace.SpanID][]*sdklog.LogData

	Calls     map[string]*callpbv1.Call
	Outputs   map[string]map[string]struct{}
	OutputOf  map[string]map[string]struct{}
	Intervals map[string]map[time.Time]*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) ExportLogs added in v0.11.0

func (db *DB) ExportLogs(ctx context.Context, logs []*sdklog.LogData) error

func (*DB) ExportSpans added in v0.11.0

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

func (*DB) HighLevelSpan added in v0.11.0

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

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) PrimarySpanForTrace added in v0.11.0

func (db *DB) PrimarySpanForTrace(traceID trace.TraceID) *Span

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) SetWidth added in v0.11.0

func (db *DB) SetWidth(width int)

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) (smallest *callpbv1.Call)

type Frontend

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

	// Plain tells the frontend to render plain console output instead of using a
	// TUI. This will be automatically set to true if a TTY is not found.
	Plain 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
	// contains filtered or unexported fields
}

func New

func New() *Frontend

func (*Frontend) Background added in v0.11.0

func (fe *Frontend) Background(cmd tea.ExecCommand) error

func (*Frontend) Close

func (fe *Frontend) Close() error

func (*Frontend) ConnectedToCloud added in v0.9.9

func (fe *Frontend) ConnectedToCloud(cloudURL string)

ConnectedToCloud is called when the CLI has started emitting events to The Cloud.

func (*Frontend) ConnectedToEngine added in v0.9.9

func (fe *Frontend) ConnectedToEngine(name string)

ConnectedToEngine is called when the CLI connects to an engine.

func (*Frontend) DumpID added in v0.9.9

func (fe *Frontend) DumpID(out *termenv.Output, id *call.ID) error

DumpID is exposed for troubleshooting.

func (*Frontend) ExportLogs added in v0.11.0

func (fe *Frontend) ExportLogs(ctx context.Context, logs []*sdklog.LogData) error

func (*Frontend) ExportSpans added in v0.11.0

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

func (*Frontend) Init added in v0.9.9

func (fe *Frontend) Init() tea.Cmd

func (*Frontend) Render

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

func (*Frontend) Run added in v0.9.9

func (fe *Frontend) Run(ctx context.Context, 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 (*Frontend) SetPrimary added in v0.11.0

func (fe *Frontend) SetPrimary(spanID trace.SpanID)

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.

func (*Frontend) SetWindowSize added in v0.11.0

func (fe *Frontend) SetWindowSize(msg tea.WindowSizeMsg)

func (*Frontend) ShouldShow added in v0.11.0

func (fe *Frontend) ShouldShow(row *TraceRow) bool

func (*Frontend) Shutdown added in v0.11.0

func (fe *Frontend) Shutdown(c context.Context) error

func (*Frontend) Update added in v0.9.9

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

func (*Frontend) View added in v0.9.9

func (fe *Frontend) View() string

type LogsView added in v0.10.0

type LogsView struct {
	Primary *Span
	Body    []*TraceRow
}

func CollectLogsView added in v0.10.0

func CollectLogsView(rows []*TraceRow) *LogsView

type Pipeline added in v0.9.9

type Pipeline []*TraceRow

func CollectPipelines added in v0.10.0

func CollectPipelines(rows []*TraceRow) []Pipeline

type Span added in v0.9.9

type Span struct {
	sdktrace.ReadOnlySpan

	Digest string

	Call *callpbv1.Call

	Internal bool
	Cached   bool
	Canceled bool
	Inputs   []string

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

func CollectSpans added in v0.11.0

func CollectSpans(db *DB, traceID trace.TraceID) []*Span

func (*Span) Bar added in v0.9.9

func (span *Span) Bar() SpanBar

func (*Span) Base added in v0.11.0

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

func (*Span) Children added in v0.11.0

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

func (*Span) Classes added in v0.11.0

func (span *Span) Classes() string

func (*Span) Duration added in v0.9.9

func (span *Span) Duration() time.Duration

func (*Span) EndTime added in v0.11.0

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

func (*Span) Err added in v0.11.0

func (span *Span) Err() error

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) Logs added in v0.11.0

func (span *Span) Logs() *Vterm

func (*Span) Name added in v0.11.0

func (span *Span) Name() string

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

func (*Trace) Name added in v0.11.0

func (trace *Trace) Name() string

func (*Trace) PrimarySpan added in v0.11.0

func (trace *Trace) PrimarySpan() *Span

type TraceRow added in v0.9.9

type TraceRow struct {
	Span *Span

	Parent *TraceRow

	IsRunning bool
	Chained   bool

	Children  []*TraceRow
	Collapsed bool
}

func CollectRows added in v0.9.9

func CollectRows(steps []*Span) []*TraceRow

func (*TraceRow) Depth added in v0.9.9

func (row *TraceRow) 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