inputtrace

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package inputtrace records what the client and the host do with the pointer and the input around it, one JSON object a line, for debugging a cursor that goes astray. Off, it costs an atomic load: callers guard with On, or call Emit, which checks it before boxing its fields.

Each record has ts (UTC, RFC 3339 with nanoseconds), t_ns (the process's transport.Mono clock, which the latency traces use too), side and kind, then the fields of its kind. Records go through a bounded queue to a goroutine that writes them; a full queue drops them, and the writer notes how many with a trace_dropped record.

Index

Constants

View Source
const (
	// MaxFileBytes is how large a trace file grows before the next one
	// starts.
	MaxFileBytes = 20 << 20
	// KeepFiles is how many trace files of a side stay, the newest.
	KeepFiles = 5
	// Env turns tracing on for a run, as the -input-trace flag does.
	Env = "PLANCK_INPUT_TRACE"
)

Variables

View Source
var (
	Client = New(SideClient)
	Host   = New(SideHost)
)

Client and Host are the process's tracers. A client app that hosts too writes both, each to its own files.

Functions

func Dir

func Dir(configDir string) string

Dir is where traces go under a config directory.

func Emit

func Emit[T any](t *Tracer, kind string, fields T)

Emit queues a record of kind with fields, which marshal to a JSON object, unless the tracer is off. It never blocks: a full queue drops the record. Fields are marshaled on the writer's goroutine, so they must not share memory the caller changes.

func EnvOn

func EnvOn() bool

EnvOn reports whether PLANCK_INPUT_TRACE asks for tracing.

Types

type Side

type Side string

Side is which end of the stream writes a trace.

const (
	SideClient Side = "client"
	SideHost   Side = "host"
)

type Tracer

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

Tracer writes one side's trace while enabled. Its methods are safe from any goroutine.

func New

func New(side Side) *Tracer

New is a tracer for side, off.

func (*Tracer) Disable

func (t *Tracer) Disable() error

Disable stops recording and returns once every record queued is on disk and the file is closed.

func (*Tracer) Dropped

func (t *Tracer) Dropped() uint64

Dropped is how many records the current trace dropped on a full queue.

func (*Tracer) Enable

func (t *Tracer) Enable(dir string) (string, error)

Enable starts a trace file in dir, keeping the newest KeepFiles of the side, and returns its path. Enabled already, it keeps the file it has.

func (*Tracer) Epoch

func (t *Tracer) Epoch() uint32

Epoch counts the times tracing turned on, so that a caller can write the context a trace needs at its start: it changes with each Enable that was off.

func (*Tracer) On

func (t *Tracer) On() bool

On reports whether the tracer records.

func (*Tracer) Path

func (t *Tracer) Path() string

Path is the file the tracer writes now, "" while off.

Jump to

Keyboard shortcuts

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