Documentation
¶
Overview ¶
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
templ: version: v0.3.1020
Index ¶
- Constants
- Variables
- func Assets() fs.FS
- func Detail(ctx context.Context, w io.Writer, page Page) error
- func Filter(traces []model.Trace, page Page) []model.Trace
- func Hosts(ctx context.Context, w io.Writer, page Page) error
- func Layout(page Page) templ.Component
- func List(ctx context.Context, w io.Writer, page Page) error
- func Live(ctx context.Context, w io.Writer, page Page) error
- func LiveScript() string
- func LiveSection(ctx context.Context, w io.Writer, page Page) error
- func Login(ctx context.Context, w io.Writer, page Page) error
- func Slowest(traces []model.Trace) time.Duration
- func Sort(traces []model.Trace, key SortKey, ascending bool)
- func Statistics(ctx context.Context, w io.Writer, page Page) error
- func StyleSheet(base string) string
- func Text(w io.Writer, page Page)
- type AxisTick
- type MemoryBudget
- type MemoryPoint
- type MemorySeries
- type Page
- func (p Page) Active(view View) bool
- func (p Page) Age(at time.Time) string
- func (p Page) AssetURL(name string) string
- func (p Page) CSSURL() string
- func (p Page) Composition(trace model.Trace) []Segment
- func (p Page) Domain() string
- func (p Page) DurationShare(trace model.Trace) float64
- func (p Page) EventsURL() string
- func (p Page) Fields() []SelectField
- func (p Page) Filtered() bool
- func (p Page) HostLiveURL(host string) string
- func (p Page) HostURL(host string) string
- func (p Page) Hosts() []model.HostStat
- func (p Page) JSURL() string
- func (p Page) KindField() SelectField
- func (p Page) KindShares() []Segment
- func (p Page) LimitOptions() []int
- func (p Page) LimitURL(limit int) string
- func (p Page) LogCount() int
- func (p Page) LogOffset(entry model.LogEntry) time.Duration
- func (p Page) LogSpan(entry model.LogEntry) *model.Span
- func (p Page) LogSpanName(entry model.LogEntry) string
- func (p Page) LoginPath() string
- func (p Page) MemorySeries() MemorySeries
- func (p Page) Now() time.Time
- func (p Page) RowsField() SelectField
- func (p Page) Service() string
- func (p Page) SortClass(key SortKey) string
- func (p Page) SortURL(key SortKey) string
- func (p Page) StatusField() SelectField
- func (p Page) StatusURL(status string) string
- func (p Page) SwitchHostURL(host string) string
- func (p Page) Ticks() []AxisTick
- func (p Page) TraceURL(id string) string
- func (p Page) TracesPath() string
- func (p Page) URL(view View) string
- func (p Page) WaveSpans() []WaveSpan
- func (p Page) WaveTrace() WaveTrace
- type Segment
- type SelectField
- type SelectOption
- type SortKey
- type SpanRow
- type View
- type WaveSpan
- type WaveTrace
Constants ¶
const AssetPrefix = "/assets/"
AssetPrefix is the route the asset tree is served under, relative to the mount path.
const FeedRows = 25
FeedRows is the number of traces the live feed holds, which the view states under the table and the handler cuts the feed to.
Variables ¶
var LimitOptions = []int{20, 50, 100, 200}
LimitOptions are the row counts offered on the trace list.
var SortKeys = []SortKey{SortAge, SortDuration, SortSpans, SortAllocated}
SortKeys lists the sortable columns, so an unknown value in a URL falls back to the default rather than sorting by nothing.
Functions ¶
func Assets ¶
Assets returns the embedded tree, whose paths line up with the URLs they are served at.
func Detail ¶
Detail renders the trace detail: the timeline, the spans, the logs and the facts beside them.
func LiveScript ¶
func LiveScript() string
LiveScript returns the embedded live view script of the debug front end. It subscribes to the event stream and swaps in the section the server renders.
func LiveSection ¶
LiveSection renders the feed alone, which is what the event stream pushes on every change: the page around it is already in the browser.
func Slowest ¶
Slowest returns the longest duration in a set of traces, used to scale the inline bars so rows compare against each other.
func Sort ¶
Sort orders traces by key. Ascending means "smallest first" for numbers and "oldest first" for age, which is what the arrow in the header claims.
func Statistics ¶
Statistics renders the rolling window grouped by route.
func StyleSheet ¶
StyleSheet returns the embedded stylesheet of the debug front end, with its asset URLs resolved against base, which is the mount path plus /assets/.
Types ¶
type AxisTick ¶
type AxisTick struct {
Label string `json:"label"`
}
AxisTick is one labelled step of the time axis under a timeline.
type MemoryBudget ¶
type MemoryBudget struct {
// Limit is the ceiling the transaction ran under, Used what it had in use
// when it finished, and Share the second as a percentage of the first.
Limit int64 `json:"limit_bytes,omitempty"`
Used int64 `json:"used_bytes,omitempty"`
HasLimit bool `json:"-"`
HasUsed bool `json:"-"`
// Peak is the largest reading any span reported, and Spans whether any of
// them did. The per span bars are drawn against the peak and not against
// the limit, which would draw a whole trace as identical slivers.
Peak int64 `json:"peak_bytes,omitempty"`
Spans bool `json:"-"`
}
MemoryBudget is the memory_limit and memory_usage a trace recorded, read off the trace and off its spans. Every part of it is optional.
func TraceMemory ¶
func TraceMemory(trace model.Trace, rows []SpanRow) MemoryBudget
TraceMemory reads the memory a trace reported, from its attributes and from the rows flattened out of its spans.
func (MemoryBudget) Known ¶
func (b MemoryBudget) Known() bool
Known reports whether the trace recorded any memory at all.
func (MemoryBudget) ShareOf ¶
func (b MemoryBudget) ShareOf(size int64) float64
ShareOf returns a reading as a percentage of the largest one in the trace.
type MemoryPoint ¶
type MemoryPoint struct {
// Name is the span the reading came from, and Offset when the span
// finished, relative to the start of the trace.
Name string `json:"name"`
Offset time.Duration `json:"offset_ns"`
Bytes int64 `json:"bytes"`
// X is the offset as a percentage of the trace width, and Y the reading
// as a percentage down from the top of the plot, both ready to draw.
X float64 `json:"x_percent"`
Y float64 `json:"y_percent"`
}
MemoryPoint is one reading on the memory graph: the memory a span reported in use when it finished, placed at the moment it finished.
type MemorySeries ¶
type MemorySeries struct {
Points []MemoryPoint `json:"points"`
// Ceiling is the top of the value scale, in bytes: the limit when it sits
// close enough to the readings to share a scale with them, the peak
// reading otherwise.
Ceiling int64 `json:"ceiling_bytes"`
// Limited reports whether the limit is drawn as a reference line, and
// LimitY where the line sits, as a percentage down from the top.
Limited bool `json:"-"`
LimitY float64 `json:"-"`
}
MemorySeries is the data behind the memory graph: the readings the spans reported, ordered by when they were taken.
func (MemorySeries) Last ¶
func (s MemorySeries) Last() MemoryPoint
Last returns the newest reading, which is the one the graph labels.
type Page ¶
type Page struct {
Snapshot model.Snapshot
View View
Path string
Title string
Limit int
Query string
Kind model.Kind
// Host is the domain filter, empty for every host. RequestHost is the
// domain this dashboard was reached on, which is the sensible default
// label when no filter is set.
Host string
RequestHost string
Status string
Sort SortKey
Ascending bool
Refresh int
Stream bool
Slowest time.Duration
// Feed is the live view: traces in flight and completed traces in one
// stream, newest first.
Feed []model.Trace
Trace *model.Trace
Rows []SpanRow
Segments []Segment
// Memory is the memory the detail view trace reported, read once because
// every row of the span table draws against it.
Memory MemoryBudget
// LoginUsername is the username a failed login was attempted with, kept so
// the form does not empty itself. LoginError is what went wrong, worded
// with what to do next.
// LoginBack is where a successful login returns to, carried through the
// redirect and the form as ?back.
LoginUsername string
LoginError string
LoginBack string
}
Page is the view model handed to every templ component. Components take nothing else, so they can be rendered in tests from a hand built page.
func NewLivePage ¶
NewLivePage builds the live view: traces in flight and completed traces merged into one feed, newest first, so a request appears the moment it starts and stays put as it finishes rather than jumping between two tables.
func NewPage ¶
NewPage builds the view model shared by every component: the snapshot to render, the page it is rendered as, and the filters the request asks for.
func (Page) Composition ¶
Composition returns the timeline of a trace scaled to the slowest trace on the page, so one row of bars compares traces against each other rather than against themselves. The shape of a request (how much of it was database, how much was waiting on someone else) is the thing worth seeing in a list.
func (Page) Domain ¶
Domain is the label of the switcher in the masthead, where unfiltered means every host rather than the one the dashboard was reached on.
func (Page) DurationShare ¶
DurationShare returns the duration of a trace relative to the slowest trace on the page.
func (Page) Fields ¶
func (p Page) Fields() []SelectField
Fields returns the filter bar controls in display order. The domain is not among them: it is chosen once in the masthead and every view inherits it.
func (Page) HostLiveURL ¶
HostLiveURL builds a link to the live feed of one host.
func (Page) KindField ¶
func (p Page) KindField() SelectField
KindField filters the list by the span kinds a trace recorded.
func (Page) KindShares ¶
KindShares totals the timeline by kind, newest share first, for the legend.
func (Page) LimitOptions ¶
LimitOptions returns the selectable row counts.
func (Page) LogSpan ¶
LogSpan returns the span an entry was written under, or nil when the entry was written outside one or the span was dropped.
func (Page) LogSpanName ¶
LogSpanName returns the name of the span an entry was written under, or nothing when the entry was written outside any open span.
func (Page) MemorySeries ¶
func (p Page) MemorySeries() MemorySeries
MemorySeries returns the readings behind the memory graph: one point per span that reported memory_usage, placed where the span finished and ordered by it. A reading is the memory in use at that moment, so the line holds flat between readings and moves where one was taken.
The scale runs to the limit when the limit is within reach of the readings, and to the peak reading when it is not: a transaction far under its limit still draws its own shape rather than a sliver along the floor.
func (Page) RowsField ¶
func (p Page) RowsField() SelectField
RowsField picks how many rows the list shows.
func (Page) SortURL ¶
SortURL builds a link that sorts by key. Clicking the active column flips the direction; clicking another column starts it at the useful end, which for every one of these is largest first.
func (Page) StatusField ¶
func (p Page) StatusField() SelectField
StatusField filters the list down to failures.
func (Page) SwitchHostURL ¶
SwitchHostURL keeps the reader on the current view and changes the domain.
func (Page) TracesPath ¶
TracesPath is where the filter form submits. It is a path with no query, because a GET form replaces the query with its own fields.
func (Page) WaveSpans ¶
WaveSpans returns every span of the trace in the shape the drawing fills: where it ran as a fraction of the trace, and how deep it sat.
The legend attributes each moment to the innermost span running, which is the right way to answer where the time went, and the wrong way to draw the stack: a request that spends its life inside three queries reports as three queries, and the handler and the request holding them never appear. The drawing wants the opposite, so it gets the spans whole. Parents included, the root included: at any moment, everything that was running.
type Segment ¶
type Segment struct {
Kind model.Kind `json:"kind"`
Offset time.Duration `json:"offset_ns"`
Duration time.Duration `json:"duration_ns"`
}
Segment is one point-in-time region of a trace where a span kind was the innermost active span.
type SelectField ¶
type SelectField struct {
ID string `json:"id"`
Name string `json:"name"`
Label string `json:"label"`
Value string `json:"value"`
Options []SelectOption `json:"options"`
}
SelectField is a dropdown on the filter bar. The control is rendered rather than delegated to a native select, because a native select cannot be styled consistently across platforms, least of all its open menu.
func (SelectField) IsSelected ¶
func (f SelectField) IsSelected(option SelectOption) bool
IsSelected reports whether an option is the chosen one.
func (SelectField) Selected ¶
func (f SelectField) Selected() string
Selected returns the label of the chosen option, falling back to the first one, so the closed control always names its own state.
type SelectOption ¶
type SelectOption struct {
Value string `json:"value"`
Label string `json:"label"`
// Note is the secondary text on the right of the option, such as a count.
Note string `json:"note,omitempty"`
}
SelectOption is one choice in a SelectField.
type SpanRow ¶
type SpanRow struct {
model.Span
Offset time.Duration `json:"offset_ns"`
Open bool `json:"open,omitempty"`
Last bool `json:"-"`
// Memory is the memory_usage the span reported, and HasMemory whether it
// reported one. Zero bytes in use and no reading are different answers.
Memory int64 `json:"memory_usage_bytes,omitempty"`
HasMemory bool `json:"-"`
}
SpanRow is the flattened render model of one span within a trace.
type View ¶
type View string
View identifies one rendered page of the debug front end.
const ( // ViewHosts is the landing page: which domains this process serves, and // how much traffic each one carries. Everything else is a drill down. ViewHosts View = "hosts" ViewList View = "list" ViewLive View = "live" ViewStats View = "stats" ViewDetail View = "detail" // ViewLogin is the sign in screen, rendered when authentication is // configured and the request carries no valid session or bearer token. It // draws none of the recorded data. ViewLogin View = "login" )
The pages the front end serves. Page.URL builds a link to any of them.
type WaveSpan ¶
type WaveSpan struct {
Name string `json:"name"`
Kind string `json:"kind"`
Color string `json:"color"`
Start float64 `json:"start"`
End float64 `json:"end"`
Depth int `json:"depth"`
Failed bool `json:"failed,omitempty"`
}
WaveSpan is one span in the shape the drawing wants: where it ran as a fraction of the trace, how deep it sat, and what colour it draws in.
Every span is handed over, parents and root included, because the drawing is of the stack: a span that wraps the whole trace is the reason there is a floor under everything else. The legend answers the other question, where the time went, and answers it from the sweep instead.
type WaveTrace ¶
type WaveTrace struct {
Milliseconds float64 `json:"ms"`
Depth int `json:"depth"`
Spans []WaveSpan `json:"spans"`
}
WaveTrace is the payload behind the drawing: the spans, how long the trace took, and how deep it nested. The duration lets the drawing work in time rather than in pixels; the depth lets it scale itself to the trace it has rather than to a number someone guessed.
Source Files
¶
- assets.go
- detail.go
- detail_templ.go
- filter.go
- funcs.go
- hosts.go
- hosts_templ.go
- layout_templ.go
- list.go
- list_templ.go
- live.go
- live_section.go
- live_templ.go
- login.go
- login_templ.go
- logs.go
- logs_templ.go
- memory.go
- memory_templ.go
- model.go
- page.go
- select_templ.go
- slowest.go
- sort.go
- statistics.go
- statistics_templ.go
- text.go
- text_logs.go
- timeline.go
- waves_templ.go