profileqlengine

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package profileqlengine implements the ProfileQL evaluation engine.

It parses ProfileQL queries, selects matching profiles from a profilestorage.Querier, and renders them into the Pyroscope-compatible flamebearer format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine is a ProfileQL evaluation engine.

func NewEngine

func NewEngine(querier profilestorage.Querier, opts Options) *Engine

NewEngine creates a new Engine.

func (*Engine) Eval

Eval parses and evaluates the query, returning a flamebearer profile.

func (*Engine) Select

func (e *Engine) Select(ctx context.Context, query string, params EvalParams) (result *Result, rerr error)

Select parses and evaluates the query, returning the merged result.

type EvalParams

type EvalParams struct {
	// Time range to select, optional.
	Start time.Time
	End   time.Time
	// MaxNodes, when positive, limits the number of nodes in the resulting
	// flamegraph; smaller nodes are folded into an "other" node.
	MaxNodes int
}

EvalParams sets evaluation parameters.

type Options

type Options struct {
	// TracerProvider provides the OpenTelemetry tracer for this engine.
	TracerProvider trace.TracerProvider
}

Options sets Engine options.

type Result

type Result struct {
	// Tree is the merged, symbol-resolved flamegraph tree. It may be nil for an
	// empty result.
	Tree *profilestorage.FlameTree
	// Type is the profile type that was selected.
	Type profileql.ProfileType
	// MaxNodes is the node limit requested for the query, if any.
	MaxNodes int
}

Result is the outcome of a ProfileQL query: a merged flamegraph tree together with the profile type it was selected for. It can be rendered into the various Pyroscope output formats.

func (*Result) Collapsed

func (r *Result) Collapsed() []byte

Collapsed renders the result into the "collapsed" (folded stacks) format: one line per stack with a non-zero self value, as a semicolon-separated list of frames (root to leaf) followed by a space and the self value.

The synthetic "total" root is omitted from the stacks.

func (*Result) Flamebearer

func (r *Result) Flamebearer() *pyroscopeapi.FlamebearerProfileV1

Flamebearer renders the result into the Pyroscope flamebearer JSON format.

func (*Result) HTML

func (r *Result) HTML() ([]byte, error)

HTML renders the result into a standalone HTML flamegraph page with the flamebearer profile embedded as JSON.

func (*Result) Pprof

func (r *Result) Pprof() ([]byte, error)

Pprof renders the result into a gzip-compressed Google pprof profile.

Each tree node with a non-zero self value becomes a sample whose stack is the path from that node up to the root (leaf-first, as pprof expects). The synthetic "total" root is omitted.

Jump to

Keyboard shortcuts

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