Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DumpMaps ¶
func DumpMaps(recipes []MetricQueryRecipe)
Types ¶
type MetricQueryRecipe ¶
type MetricQueryRecipe interface {
// Return the basename associated with this recipe; all metrics yielded
// will be prefixed with this
GetNamespace() string
// Returns a map to be used in interpreting the result of Run(): each
// column in the resultset should be looked up in this map to determine
// how to handle it.
GetResultMaps() MultiResultMap
// Run executes one or more queries and returns one or more resultsets.
// There need not be a one-to-one mapping.
Run(db.Conn) ([]db.ScannedResultSet, error)
}
MetricQueryRecipe is a collection of rules that specify how to produce a set of related metrics given a DB connection. In other words, it knows how to issue query(s) and interpret the results.
type MetricQueryRecipeBase ¶
type MetricQueryRecipeBase struct {
// Namespace is typically the name of a table to query, and it provides
// the base name of derived metrics (after the driver prefix).
Namespace string
// ResultMaps maps column names in resultsets to the ColumnMapping
// that should be used to build a metric.
Resultmaps MultiResultMap
}
MetricQueryRecipeBase is common to all recipes.
func (*MetricQueryRecipeBase) GetNamespace ¶
func (mqrb *MetricQueryRecipeBase) GetNamespace() string
GetNamespace implements MetricQueryRecipe.
func (*MetricQueryRecipeBase) GetResultMaps ¶
func (mqrb *MetricQueryRecipeBase) GetResultMaps() MultiResultMap
GetResultMaps implements MetricQueryRecipe.
type MetricQueryRecipeSimple ¶
type MetricQueryRecipeSimple struct {
*MetricQueryRecipeBase
// sqlquery is what should be executed
Queries []string
}
func (*MetricQueryRecipeSimple) Run ¶
func (mqrs *MetricQueryRecipeSimple) Run(conn db.Conn) ([]db.ScannedResultSet, error)
type MetricQueryRecipeTemplated ¶
type MetricQueryRecipeTemplated struct {
*MetricQueryRecipeBase
// Rangequery returns a single-column resultset over which to iterate
Rangequery string
// All templates are executed in the context of a range over the rangequery results.
// Each resulting string is executed as an SQL query, and the resulting resultsets
// are returned by the ResultSet (after filtering out empty resultsets.)
Queries []*template.Template
}
func (*MetricQueryRecipeTemplated) Run ¶
func (mqrt *MetricQueryRecipeTemplated) Run(conn db.Conn) ([]db.ScannedResultSet, error)
type MultiResultMap ¶
type MultiResultMap []NamedResultMap
MultiResultMap describes how to handle a list of resultsets, as can be returned by some queries in DBs like Sybase and SQL Server. Resultset don't intrically have names, just positions, but we're imposing a name so that we can craft metrics based on it.
type NamedResultMap ¶
NamedResultMap associates a name with a ResultMap based on configuration.
func (NamedResultMap) ShouldSkip ¶
func (nrm NamedResultMap) ShouldSkip() bool
ShouldSkip returns true if this resultset should be ignored.
type ResultMap ¶
type ResultMap map[string]common.ColumnMapping
ResultMap describes how to handle a single resultset, i.e. how each column should be interpreted in terms of metrics.