flight_trace

package module
v0.0.0-...-ab359ad Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 9 Imported by: 3

README

flight_trace

The flight_trace package provides a lightweight wrapper around the Go runtime Flight Recorder (Go 1.25+),
allowing you to programmatically control and dump runtime traces.

🧩 Features

  • Initializes runtime/trace.FlightRecorder with graceful shutdown via context.Context
  • Configuration through Viper (FLIGHT_RECORDER_* environment variables)
  • On-demand dump creation (DumpSnapshot, DumpSnapshotAsync)
  • Framework-agnostic — works in HTTP, gRPC, CLI, or background workers

🔌 Middleware

⚙️ Configuration

Variable Type Description Default
FLIGHT_RECORDER_ENABLED bool Enable Flight Recorder true
FLIGHT_RECORDER_MIN_AGE duration Minimum age of samples to retain 1s
FLIGHT_RECORDER_MAX_BYTES uint64 Maximum buffer size in bytes 20971520 (20 MB)
FLIGHT_RECORDER_DUMP_PATH string Directory for dump files /tmp/flight_dumps

📚 References


Minimal dependencies. Maximum observability.
Use flight_trace as a standalone utility or integrate it into your SDK.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRecorderNotInitialized = errors.New("flight recorder not initialized")
	ErrRecorderNotStarted     = errors.New("flight recorder not started")
	ErrCreateDumpPath         = errors.New("failed to create dump path")
	ErrCreateDumpFile         = errors.New("failed to create dump file")
	ErrWriteDump              = errors.New("failed to write flight dump")
	ErrStartRecorder          = errors.New("failed to start flight recorder")
)

Functions

This section is empty.

Types

type Recorder

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

Recorder manages Go's Flight Recorder lifecycle and dump rotation.

func New

func New(ctx context.Context, cfg *config.Config) (*Recorder, error)

New initializes the Flight Recorder and starts background cleanup.

func (*Recorder) DumpToFile

func (wr *Recorder) DumpToFile(fileName string) error

DumpToFile writes the flight recorder buffer into a file under dumpPath.

func (*Recorder) DumpToFileAsync

func (wr *Recorder) DumpToFileAsync(fileName string)

DumpToFileAsync runs DumpToFile asynchronously.

Jump to

Keyboard shortcuts

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