Help us shape the future of Go! Take the 2026 Go Developer Survey

jfr

package
v0.1.60 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package jfr is a trace kind that profiles a JVM with a JFR recording, made by the JDK's Flight Recorder or by async-profiler, and stores what each dump of the recording adds as samples aggregated by stack.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewKindFor

func NewKindFor[P Recordable](recorder Recorder) *tracing.Handler[P, Sample]

NewKindFor is the jfr kind over recorder for a host's own params type, its stacks cut at 64KiB.

Types

type Engine

type Engine string

Engine is what records a JVM's profile into a JFR recording.

const (
	// EngineJFR is the JDK's own Flight Recorder (JDK 8u262 and later),
	// recording every profiling event its Settings enable.
	EngineJFR Engine = "jfr"
	// EngineAsyncProfiler is async-profiler in its jfr output mode, profiling
	// one Event per session.
	EngineAsyncProfiler Engine = "async-profiler"
)

type Options

type Options struct {
	Engine Engine
	// Event is the one event async-profiler profiles; the JDK's recorder
	// takes its events from Settings instead.
	Event string
	// Settings is the JDK recorder's predefined configuration, such as
	// "profile" or "default".
	Settings string
	// Interval is async-profiler's sampling interval; zero is its own. The
	// JDK recorder takes its periods from Settings.
	Interval time.Duration
	// Every dumps the recording at that interval while the capture runs; zero
	// dumps only at checkpoints and as the capture stops.
	Every time.Duration
	// Threads splits each stack's samples by the thread they were taken on.
	Threads bool
	// MaxStackDepth keeps only the leaf-most frames of deeper stacks; zero
	// keeps every frame the recorder recorded.
	MaxStackDepth int
}

Options are what a capture records and how it reads the recording back.

func (Options) String

func (o Options) String() string

String is what the recording profiles, as its session shows it.

func (Options) Validate

func (o Options) Validate() error

Validate refuses options a recording could not honour.

type Recordable

type Recordable interface {
	JFROptions() (Options, error)
}

Recordable is a params type that maps itself onto the recording it starts. The kind validates the options as the capture starts; a host's Validate should too, so a start it cannot honour is refused before a session exists.

type Recorder

type Recorder interface {
	// Start begins a recording named name with options.
	Start(ctx context.Context, options Options, name string) (Recording, error)
}

Recorder starts recordings in the JVM a host profiles: it is the kind's transport, which a host provides.

type Recording

type Recording interface {
	// Dump returns the whole recording so far as a JFR file, uncompressed:
	// one or more chunks, beginning with the "FLR\0" magic. The kind decodes
	// only the events that end after the previous dump's latest.
	Dump(ctx context.Context) ([]byte, error)
	// Stop ends the recording and frees what it holds in the JVM.
	Stop(ctx context.Context) error
	// Handle names the recording in the JVM; the session is named after it.
	Handle() string
	// Metadata describes how the recording was started, such as the commands
	// that started it.
	Metadata() []query.SessionMetadata
}

Recording is a running recording.

type Report

type Report struct {
	Engine    Engine           `json:"engine"`
	Recording string           `json:"recording"`
	Dumps     int              `json:"dumps"`
	Bytes     int64            `json:"bytes"`
	Events    map[string]int64 `json:"events"`
	// Latest is the watermark: the latest event stored, after which the next
	// dump's events are new.
	Latest time.Time `json:"latest,omitzero"`
}

Report is a capture's summary: the recording it dumped, how often and how much, the samples it stored by event, and its watermark.

type Sample

type Sample struct {
	tracing.Truncation
	decode.StackSample
}

Sample is the record the jfr kind stores: a StackSample, truncated as the kind's processors cut it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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