Documentation
¶
Overview ¶
Package profileql contains a parser and AST definitions for the Pyroscope profile query language.
A ProfileQL query is a profile-type selector optionally followed by a brace enclosed list of label matchers, mirroring Pyroscope's query syntax (a Prometheus metric selector whose __name__ is the profile type):
process_cpu:cpu:nanoseconds:cpu:nanoseconds{service_name="frontend",env=~"prod|staging"}
Index ¶
Constants ¶
const ( // LabelName is the label holding the profile-type selector, equivalent to // Prometheus' __name__ metric name label. LabelName = "__name__" // LabelServiceName is the conventional service name label. LabelServiceName = "service_name" // LabelProfileType is the internal label holding the profile type. LabelProfileType = "__profile_type__" )
Variables ¶
This section is empty.
Functions ¶
func IsValidLabel ¶
IsValidLabel validates a label name.
Types ¶
type Expr ¶
type Expr struct {
// Type is the parsed profile-type selector.
Type ProfileType
// Matchers are the label matchers, excluding the profile-type ([LabelName])
// matcher.
Matchers []LabelMatcher
}
Expr is a parsed ProfileQL query: a profile-type selector together with a set of label matchers.
The textual form is a profile-type selector optionally followed by a brace enclosed list of label matchers, for example
process_cpu:cpu:nanoseconds:cpu:nanoseconds{service_name="frontend"}
mirroring Pyroscope's query syntax, which is a Prometheus metric selector whose __name__ is the profile type.
type LabelMatcher ¶
type LabelMatcher struct {
Label Label
Op MatchOp // OpEq, OpNotEq, OpRe, OpNotRe
Value string // Equals to value or to the unparsed regexp
Re *regexp.Regexp // Equals to nil, if Op is not OpRe or OpNotRe
}
LabelMatcher is a label matching predicate.
type MatchOp ¶
type MatchOp int
MatchOp defines a label matching operation.
type ParseError ¶
ParseError is a ProfileQL query parsing error.
func (*ParseError) FormatError ¶
func (e *ParseError) FormatError(p errors.Printer) error
FormatError implements errors.Formatter.
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
Unwrap implements the errors.Unwrap interface.
type ProfileType ¶
type ProfileType struct {
// Name is the profile name, e.g. "process_cpu" or "memory".
Name string
// SampleType is the sample value type, e.g. "cpu" or "alloc_space".
SampleType string
// SampleUnit is the sample value unit, e.g. "nanoseconds" or "bytes".
SampleUnit string
// PeriodType is the period type, e.g. "cpu".
PeriodType string
// PeriodUnit is the period unit, e.g. "nanoseconds".
PeriodUnit string
// Delta denotes that the profile carries delta values.
Delta bool
}
ProfileType is a parsed profile-type selector.
The textual form is
<name>:<sample_type>:<sample_unit>:<period_type>:<period_unit>[:delta]
for example "process_cpu:cpu:nanoseconds:cpu:nanoseconds".
func ParseProfileType ¶
func ParseProfileType(id string) (ProfileType, error)
ParseProfileType parses a profile-type selector string.
func (ProfileType) ID ¶
func (t ProfileType) ID() string
ID returns the canonical 5-part profile-type identifier, without the delta suffix. This is the value stored in the LabelProfileType label.
func (ProfileType) String ¶
func (t ProfileType) String() string
String implements fmt.Stringer. It reproduces the parsed form, including the delta suffix when set.
type Selector ¶
type Selector struct {
// Type is the selected profile type, or nil if the selector did not name one.
Type *ProfileType
// Matchers are the label matchers, excluding the profile-type selection.
Matchers []LabelMatcher
}
Selector is the result of parsing a label selector with an optional profile type, as produced by ParseSelector.
func ParseSelector ¶
ParseSelector parses an optional leading profile-type selector followed by an optional brace-enclosed matcher list, like Parse, but the profile type is optional. It is used where the profile type and label selector are supplied separately (for example by the connect QuerierService), so a bare matcher list such as `{service.name="frontend"}` is valid.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package lexer contains ProfileQL lexer.
|
Package lexer contains ProfileQL lexer. |
|
Package profileqlengine implements the ProfileQL evaluation engine.
|
Package profileqlengine implements the ProfileQL evaluation engine. |