Documentation
¶
Overview ¶
Package gnomon is a tiny, standardized BI layer: register business metrics (live ReadThrough or daily Snapshot), then capture and serve them. It owns no scheduling and no auth -- the host wires Capture into its own job runner and wraps adminhttp with its own auth middleware.
Index ¶
- Variables
- type Chart
- type DataSource
- type Gnomon
- func (g *Gnomon) Capture(ctx context.Context, on time.Time) error
- func (g *Gnomon) Metrics() []Metric
- func (g *Gnomon) Query(ctx context.Context, name string) ([]Row, error)
- func (g *Gnomon) Register(ms ...Metric) error
- func (g *Gnomon) Series(ctx context.Context, name string, from, to time.Time) ([]Point, error)
- type Kind
- type Measure
- type Metric
- type Point
- type Row
- type Sample
- type Store
- type Unit
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownMetric = errors.New("gnomon: unknown metric")
ErrUnknownMetric is returned by Query and Series when the requested metric name has not been registered.
var ErrWrongKind = errors.New("gnomon: wrong metric kind")
ErrWrongKind is returned by Query when called on a Snapshot metric, or by Series when called on a ReadThrough metric.
Functions ¶
This section is empty.
Types ¶
type DataSource ¶
DataSource runs metric SQL against the host's data database.
type Gnomon ¶
type Gnomon struct {
// contains filtered or unexported fields
}
Gnomon is the engine: a metric registry over a DataSource + Store.
func New ¶
func New(data DataSource, store Store) *Gnomon
func (*Gnomon) Capture ¶
Capture runs every registered Snapshot metric's SQL, parses the rows into samples, and upserts them stamped with on. ReadThrough metrics are skipped. One metric's failure does not abort the rest; all errors are joined.
A snapshot metric is all-or-nothing per capture: if any row fails to parse, that metric's entire sample set for the day is skipped and the error is joined (other metrics still capture).
func (*Gnomon) Query ¶
Query runs a ReadThrough metric and returns its rows. It errors if the metric is unknown or is not a ReadThrough metric.
type Measure ¶ added in v0.4.0
Measure is one plotted/displayed series within a metric: which row column to read, an optional display label, and the unit to format it with.
type Metric ¶
type Metric struct {
Name string
Title string
Kind Kind
SQL string
Unit Unit
Chart Chart
Dimension string
Measures []Measure
}
Metric is a single registered metric. For Snapshot kind, SQL must return a value column and may return a dimension column. For ReadThrough kind, SQL may return arbitrary columns; Dimension names the x-axis column and Measures names the columns to plot/show (in order).
type Point ¶
type Point struct {
CapturedOn time.Time `json:"captured_on"`
Dimension string `json:"dimension"`
Value float64 `json:"value"`
}
Point is one stored snapshot data point read back from the store.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package adminhttp exposes a mountable, auth-agnostic JSON handler for serving gnomon metric metadata, live ReadThrough results, and stored Snapshot series.
|
Package adminhttp exposes a mountable, auth-agnostic JSON handler for serving gnomon metric metadata, live ReadThrough results, and stored Snapshot series. |
|
Package experiments provides a tiny frequentist A/B analysis core: compare treatment arms to a control with a two-proportion z-test, reporting lift, significance, and a confidence interval.
|
Package experiments provides a tiny frequentist A/B analysis core: compare treatment arms to a control with a two-proportion z-test, reporting lift, significance, and a confidence interval. |
|
Package sourcepg provides a Postgres-backed gnomon.DataSource + gnomon.Store over a gnomon_snapshots table.
|
Package sourcepg provides a Postgres-backed gnomon.DataSource + gnomon.Store over a gnomon_snapshots table. |