pyroscope

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatLabelsTable

func FormatLabelsTable(w io.Writer, labels []string) error

FormatLabelsTable formats label names or values as a table.

func FormatProfileTypesTable

func FormatProfileTypesTable(w io.Writer, resp *ProfileTypesResponse) error

FormatProfileTypesTable formats profile types as a table.

func FormatQueryTable

func FormatQueryTable(w io.Writer, resp *QueryResponse) error

FormatQueryTable formats a Pyroscope query response as a table showing top functions.

Types

type Client

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

Client is a client for executing Pyroscope queries via Grafana's datasource API.

func NewClient

func NewClient(cfg config.NamespacedRESTConfig) (*Client, error)

NewClient creates a new Pyroscope query client.

func (*Client) LabelNames

func (c *Client) LabelNames(ctx context.Context, datasourceUID string, req LabelNamesRequest) (*LabelNamesResponse, error)

LabelNames returns label names from the datasource.

func (*Client) LabelValues

func (c *Client) LabelValues(ctx context.Context, datasourceUID string, req LabelValuesRequest) (*LabelValuesResponse, error)

LabelValues returns values for a specific label.

func (*Client) ProfileTypes

func (c *Client) ProfileTypes(ctx context.Context, datasourceUID string, req ProfileTypesRequest) (*ProfileTypesResponse, error)

ProfileTypes returns available profile types from the datasource.

func (*Client) Query

func (c *Client) Query(ctx context.Context, datasourceUID string, req QueryRequest) (*QueryResponse, error)

Query executes a Pyroscope profile query against the specified datasource.

type Flamegraph

type Flamegraph struct {
	Names   []string `json:"names"`
	Levels  []Level  `json:"levels"`
	Total   int64    `json:"total,string"`
	MaxSelf int64    `json:"maxSelf,string"`
}

Flamegraph represents a flame graph structure.

type FunctionSample

type FunctionSample struct {
	Name       string
	Self       int64
	Total      int64
	Percentage float64
}

FunctionSample represents a function in the flame graph with computed stats.

func ExtractTopFunctions

func ExtractTopFunctions(fg *Flamegraph, limit int) []FunctionSample

ExtractTopFunctions extracts the top N functions by self time from a flame graph.

type LabelNamesRequest

type LabelNamesRequest struct {
	Matchers []string
	Start    time.Time
	End      time.Time
}

LabelNamesRequest represents a request to list label names.

type LabelNamesResponse

type LabelNamesResponse struct {
	Names []string `json:"names"`
}

LabelNamesResponse represents the response from a label names query.

type LabelValuesRequest

type LabelValuesRequest struct {
	Name     string
	Matchers []string
	Start    time.Time
	End      time.Time
}

LabelValuesRequest represents a request to list label values.

type LabelValuesResponse

type LabelValuesResponse struct {
	Names []string `json:"names"` // Pyroscope uses "names" for both labels and values
}

LabelValuesResponse represents the response from a label values query.

type Level

type Level struct {
	Values []string `json:"values"` // API returns strings that need to be parsed
}

Level represents a single level in the flame graph.

type ProfileType

type ProfileType struct {
	ID         string `json:"ID"`
	Name       string `json:"name"`
	SampleType string `json:"sampleType"`
	SampleUnit string `json:"sampleUnit"`
	PeriodType string `json:"periodType"`
	PeriodUnit string `json:"periodUnit"`
}

ProfileType represents a profile type in Pyroscope.

type ProfileTypesRequest

type ProfileTypesRequest struct {
	Start time.Time
	End   time.Time
}

ProfileTypesRequest represents a request to list profile types.

type ProfileTypesResponse

type ProfileTypesResponse struct {
	ProfileTypes []ProfileType `json:"profileTypes"`
}

ProfileTypesResponse represents the response from a profile types query.

type QueryRequest

type QueryRequest struct {
	LabelSelector string
	ProfileTypeID string
	Start         time.Time
	End           time.Time
	MaxNodes      int64
}

QueryRequest represents a Pyroscope profile query request.

func (QueryRequest) IsRange

func (r QueryRequest) IsRange() bool

IsRange returns true if this is a range query with explicit time bounds.

type QueryResponse

type QueryResponse struct {
	Flamegraph *Flamegraph `json:"flamegraph,omitempty"`
}

QueryResponse represents the response from a Pyroscope profile query.

Jump to

Keyboard shortcuts

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