Documentation ¶
Index ¶
- Constants
- Variables
- func CanParallelize(expr parser.Expr, logger log.Logger) bool
- func ParallelizableFunc(f parser.Function) bool
- func VectorSquasher(exprs ...EmbeddedQuery) (parser.Expr, error)
- type ASTExprMapper
- type ASTMapper
- func NewInstantQuerySplitter(ctx context.Context, interval time.Duration, logger log.Logger, ...) ASTMapper
- func NewQueryPruner(ctx context.Context, logger log.Logger) ASTMapper
- func NewQueryShardSummer(ctx context.Context, shards int, squasher Squasher, logger log.Logger, ...) (ASTMapper, error)
- func NewShardSummerWithLabeller(ctx context.Context, shards int, squasher Squasher, logger log.Logger, ...) (ASTMapper, error)
- func NewSharding(shardSummer ASTMapper) ASTMapper
- type EmbeddedQueries
- type EmbeddedQuery
- type ExprMapper
- type InstantSplitterStats
- type MapperStats
- type MultiMapper
- type ShardLabeller
- type SkippedReason
- type Squasher
Constants ¶
const ( // EmbeddedQueriesLabelName is a reserved label name containing embedded queries. EmbeddedQueriesLabelName = "__queries__" // EmbeddedQueriesMetricName is a reserved metric name denoting a special metric which contains embedded queries. EmbeddedQueriesMetricName = "__embedded_queries__" )
const ( SkippedReasonSmallInterval = SkippedReason("small-interval") SkippedReasonSubquery = SkippedReason("subquery") SkippedReasonNonSplittable = SkippedReason("non-splittable") )
Possible skipped reasons
Variables ¶
var FuncsWithDefaultTimeArg = []string{
"day_of_month",
"day_of_week",
"day_of_year",
"days_in_month",
"hour",
"minute",
"month",
"year",
}
FuncsWithDefaultTimeArg is the list of functions that extract date information from a variadic list of params, which defaults to be just time() otherwise.
var JSONCodec jsonCodec
JSONCodec is a Codec that uses JSON representations of EmbeddedQueries structs
var NonParallelFuncs = []string{
"absent",
"absent_over_time",
"info",
"histogram_quantile",
"limitk",
"limit_ratio",
"sort_desc",
"sort_by_label",
"sort_by_label_desc",
"sort",
"time",
"vector",
"histogram_avg",
}
NonParallelFuncs is the list of functions that shouldn't be parallelized.
Functions ¶
func CanParallelize ¶
CanParallelize tests if a subtree is parallelizable. A subtree is parallelizable if all of its components are parallelizable.
func ParallelizableFunc ¶
ParallelizableFunc ensures that a promql function can be part of a parallel query.
func VectorSquasher ¶
func VectorSquasher(exprs ...EmbeddedQuery) (parser.Expr, error)
VectorSquash reduces multiple EmbeddedQueries into a single vector query which can be hijacked by a Queryable impl. It always uses a VectorSelector as the substitution expr. This is important because logical/set binops can only be applied against vectors and not matrices.
Types ¶
type ASTExprMapper ¶
type ASTExprMapper struct {
ExprMapper
}
ASTExprMapper is an ASTMapper adapter which uses a ExprMapper internally.
func NewASTExprMapper ¶
func NewASTExprMapper(mapper ExprMapper) ASTExprMapper
NewASTExprMapper creates an ASTMapper from a ExprMapper
type ASTMapper ¶
type ASTMapper interface { // Map the input expr and returns the mapped expr. Map(expr parser.Expr) (mapped parser.Expr, err error) }
ASTMapper is the exported interface for mapping between multiple AST representations
func NewInstantQuerySplitter ¶
func NewInstantQuerySplitter(ctx context.Context, interval time.Duration, logger log.Logger, stats *InstantSplitterStats) ASTMapper
NewInstantQuerySplitter creates a new query range mapper.
func NewQueryShardSummer ¶
func NewQueryShardSummer(ctx context.Context, shards int, squasher Squasher, logger log.Logger, stats *MapperStats) (ASTMapper, error)
NewQueryShardSummer instantiates an ASTMapper which will fan out sum queries by shard.
func NewShardSummerWithLabeller ¶
func NewShardSummerWithLabeller(ctx context.Context, shards int, squasher Squasher, logger log.Logger, stats *MapperStats, labeller ShardLabeller) (ASTMapper, error)
func NewSharding ¶
NewSharding creates a new query sharding mapper.
type EmbeddedQueries ¶
type EmbeddedQueries struct {
Concat []EmbeddedQuery `json:"Concat"`
}
EmbeddedQueries is a wrapper type for encoding queries
type EmbeddedQuery ¶
type EmbeddedQuery struct { Expr string `json:"Expr"` Params map[string]string `json:"Params,omitempty"` }
func NewEmbeddedQuery ¶
func NewEmbeddedQuery(expr string, params map[string]string) EmbeddedQuery
type ExprMapper ¶
type InstantSplitterStats ¶
type InstantSplitterStats struct {
// contains filtered or unexported fields
}
func NewInstantSplitterStats ¶
func NewInstantSplitterStats() *InstantSplitterStats
func (*InstantSplitterStats) AddSplitQueries ¶
func (s *InstantSplitterStats) AddSplitQueries(num int)
AddSplitQueries add num split queries to the counter.
func (*InstantSplitterStats) GetSkippedReason ¶
func (s *InstantSplitterStats) GetSkippedReason() SkippedReason
GetSkippedReason returns the reason a query is a no operation. If number of split queries is greater than 0, it means the query is splittable Otherwise, if no skipped reason is set, it means the query is non-splittable
func (*InstantSplitterStats) GetSplitQueries ¶
func (s *InstantSplitterStats) GetSplitQueries() int
GetSplitQueries returns the number of split queries.
func (*InstantSplitterStats) SetSkippedReason ¶
func (s *InstantSplitterStats) SetSkippedReason(reason SkippedReason)
SetSkippedReason set no operation reason for query.
type MapperStats ¶
type MapperStats struct {
// contains filtered or unexported fields
}
func NewMapperStats ¶
func NewMapperStats() *MapperStats
func (*MapperStats) AddShardedQueries ¶
func (s *MapperStats) AddShardedQueries(num int)
AddShardedQueries add num sharded queries to the counter.
func (*MapperStats) GetShardedQueries ¶
func (s *MapperStats) GetShardedQueries() int
GetShardedQueries returns the number of sharded queries.
type MultiMapper ¶
type MultiMapper struct {
// contains filtered or unexported fields
}
MultiMapper can compose multiple ASTMappers
func NewMultiMapper ¶
func NewMultiMapper(xs ...ASTMapper) *MultiMapper
NewMultiMapper instantiates an ASTMapper from multiple ASTMappers.
func (*MultiMapper) Register ¶
func (m *MultiMapper) Register(xs ...ASTMapper)
Register adds ASTMappers into a multimapper. Since registered functions are applied in the order they're registered, it's advised to register them in decreasing priority and only operate on exprs that each function cares about, defaulting to cloneExpr.
type ShardLabeller ¶
type SkippedReason ¶
type SkippedReason string