plan

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package plan provides the Loader singleton that loads metric collection plans.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFile

func ReadFile(file string) (blip.Plan, error)

func ReadTable

func ReadTable(table string, db *sql.DB, monitorId string) ([]blip.Plan, error)

func ReadVariable

func ReadVariable(strVal, planName string) (blip.Plan, error)

func ValidatePlans

func ValidatePlans(plans []blip.Plan) error

ValidatePlans returns nil if all plans are valid, else it returns an error that lists each validation error.

Types

type Loader

type Loader struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

PlanLooader is a singleton service and repo for level plans.

func NewLoader

func NewLoader(plugin func(blip.ConfigPlans) ([]blip.Plan, error)) *Loader

func (*Loader) LoadMonitor

func (pl *Loader) LoadMonitor(mon blip.ConfigMonitor, dbMaker blip.DbFactory) error

Monitor plans: config.monitors.*.Plans

func (*Loader) LoadShared

func (pl *Loader) LoadShared(cfg blip.ConfigPlans, dbMaker blip.DbFactory) error

LoadShared loads all top-level (shared) plans: config.Plans. These plans are called "shared" because more than one monitor can use them, which is the normal case. For example, the simplest configurate is specifying a single shared plan that almost monitors use implicitly (by not specifcying config.monitors.*.Plans).

This method is called by Server.Boot(). Plans from a table are deferred until the monitor's LPC calls Plan() because the monitor might not be online when Blip starts.

func (*Loader) MonitorPlans

func (pl *Loader) MonitorPlans(ids ...string) map[string][]Meta

func (*Loader) Plan

func (pl *Loader) Plan(monitorId string, planName string, db *sql.DB) (blip.Plan, error)

Plan returns the plan for the given monitor.

func (*Loader) Print

func (pl *Loader) Print()

func (*Loader) SharedPlans

func (pl *Loader) SharedPlans() []Meta

type Meta

type Meta struct {
	Name   string
	Source string
	Shared bool
	YAML   string // plan converted to YAML
	// contains filtered or unexported fields
}

Meta is a blip.Plan plus metadata.

type SortedLevel

type SortedLevel struct {
	Freq int
	Name string
}

SortedLevel represents a sorted level created by sortedLevels below.

func Sort

func Sort(p *blip.Plan) []SortedLevel

Sort returns a list of levels sorted (asc) by frequency. Sorted levels are used in the main Run loop: for i := range c.levels. Sorted levels are required because plan levels are unorded because the plan is a map. We could check every level in the plan, but that's wasteful. With sorted levels, we can precisely check which levels to collect at every 1s tick.

Also, plan levels are abbreviated whereas sorted levels are complete. For example, a plan says "collect X every 5s, and collect Y every 10s". But the complete version of that is "collect X every 5s, and collect X + Y every 10s." See "metric inheritance" in the docs.

Also, we convert duration strings from the plan level to integers for sorted levels in order to do modulo (%) in the main Run loop.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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