Documentation
¶
Index ¶
- func FormatLabelsTable(w io.Writer, labels []string) error
- func FormatProfileTypesTable(w io.Writer, resp *ProfileTypesResponse) error
- func FormatQueryTable(w io.Writer, resp *QueryResponse) error
- type Client
- func (c *Client) LabelNames(ctx context.Context, datasourceUID string, req LabelNamesRequest) (*LabelNamesResponse, error)
- func (c *Client) LabelValues(ctx context.Context, datasourceUID string, req LabelValuesRequest) (*LabelValuesResponse, error)
- func (c *Client) ProfileTypes(ctx context.Context, datasourceUID string, req ProfileTypesRequest) (*ProfileTypesResponse, error)
- func (c *Client) Query(ctx context.Context, datasourceUID string, req QueryRequest) (*QueryResponse, error)
- type Flamegraph
- type FunctionSample
- type LabelNamesRequest
- type LabelNamesResponse
- type LabelValuesRequest
- type LabelValuesResponse
- type Level
- type ProfileType
- type ProfileTypesRequest
- type ProfileTypesResponse
- type QueryRequest
- type QueryResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatLabelsTable ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.