v0.6.0 aba298d

timeline.go RawHistoryFolder

1// SPDX-License-Identifier: MIT
2
3package host
4
5import "time"
6
7// timeline is the per-phase timing of a job, logged on its "job finished"
8// line: durations in milliseconds (the *_ms keys) and counters. A jobRun
9// creates it once, in startJob; it is guarded by jobRun.mu.
10type timeline map[string]int64
11
12// setMs records d as the duration of a phase, in whole milliseconds.
13func (t timeline) setMs(key string, d time.Duration) { t[key] = max(0, d.Milliseconds()) }
14
15// addMs adds d to the summed duration of a phase that may run several times.
16func (t timeline) addMs(key string, d time.Duration) { t[key] += max(0, d.Milliseconds()) }
17
18// add adds n to a counter.
19func (t timeline) add(key string, n int64) { t[key] += n }
20
21// guestBootKeys are the boot phases the guest may report in its Hello: the
22// host logs these as guest_<key>_ms and ignores any other key, as it does not
23// trust the guest.
24var guestBootKeys = []string{"kernel", "setup", "containerd", "dockerd"}
25
26// addGuestBoot records the guest's boot phases: known keys with a value of
27// at least 0.
28func (t timeline) addGuestBoot(ms map[string]int64) {
29	for _, k := range guestBootKeys {
30		if v, ok := ms[k]; ok && v >= 0 {
31			t["guest_"+k+"_ms"] = v
32		}
33	}
34}
35
36func (j *jobRun) timeSet(key string, d time.Duration) {
37	j.mu.Lock()
38	defer j.mu.Unlock()
39	j.timeline.setMs(key, d)
40}
41
42// timingFields sets total_ms and returns a copy of the timeline for the log.
43func (j *jobRun) timingFields() map[string]any {
44	j.mu.Lock()
45	defer j.mu.Unlock()
46	j.timeline.setMs("total_ms", time.Since(j.receivedAt))
47	fields := make(map[string]any, len(j.timeline))
48	for k, v := range j.timeline {
49		fields[k] = v
50	}
51	return fields
52}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 4

Tags 11

↑↓ moveenter openesc close