perf

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Span

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

Span tracks timing for an operation and its substeps. A Span is not safe for concurrent use from multiple goroutines.

func Start

func Start(ctx context.Context, name string, attrs ...slog.Attr) (context.Context, *Span)

Start begins a new span. If ctx already has a span, the new one becomes a child. Returns the updated context and the span. Call span.End() when the operation completes.

func (*Span) End

func (s *Span) End()

End completes the span. For root spans, emits a single DEBUG log line with the full timing tree. For child spans, records the duration only. Safe to call multiple times -- subsequent calls are no-ops.

func (*Span) RecordError

func (s *Span) RecordError(err error)

RecordError marks the span as errored. Only the first non-nil error is stored; subsequent calls are no-ops. Call this before End() on error paths.

Jump to

Keyboard shortcuts

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