Documentation ¶
Index ¶
- Constants
- Variables
- func AppendField(data []byte, labels, values []string) []byte
- func AppendMatch(data []byte, s string) []byte
- func AppendMatchField(data []byte, labels []string, group []string, q map[string]string) []byte
- func CollectResults(scan <-chan ScanResult) <-chan Results
- func Field(labels, values []string) (f string)
- func MatchField(labels []string, group []string, q map[string]string) (f string)
- func QueryPermutations(input url.Values) []map[string]string
- func TimeSequence(start time.Time, end time.Time, unit time.Duration) []time.Time
- type Collector
- type Controller
- type Counter
- type Counters
- type DB
- func (db DB) AppendKey(data []byte, r Resolution, event string, t time.Time) []byte
- func (db *DB) ExactQuery(results chan<- ScanResult, q Query) error
- func (db *DB) Gather(col Collector, tm time.Time) (err error)
- func (db DB) Key(r Resolution, event string, t time.Time) (k string)
- func (db *DB) Query(queries ...Query) (Results, error)
- func (db *DB) ScanQuery(results chan<- ScanResult, q Query) (err error)
- func (db *DB) ValueScan(results chan<- ScanResult, q Query) error
- type DataPoint
- type DataPoints
- type Desc
- func (d *Desc) Describe() *Desc
- func (d *Desc) Error() error
- func (d *Desc) HasLabel(label string) bool
- func (d *Desc) LabelIndex(label string) int
- func (d *Desc) LabelValues(values []string) LabelValues
- func (d *Desc) Labels() []string
- func (e *Desc) MatchingQueries(q url.Values) url.Values
- func (d *Desc) Name() string
- func (d *Desc) Resolution(name string) (r Resolution, ok bool)
- func (d *Desc) Resolutions() []Resolution
- func (d *Desc) Type() MetricType
- type Descriptor
- type Event
- type FrequencyMap
- type Gatherer
- type LabelValues
- type Metric
- type MetricType
- type Query
- type QueryBuilder
- func (q QueryBuilder) At(res Resolution) QueryBuilder
- func (q QueryBuilder) Between(start, end time.Time) QueryBuilder
- func (q QueryBuilder) Exact() QueryBuilder
- func (q QueryBuilder) From(event ...string) QueryBuilder
- func (q QueryBuilder) GroupBy(label ...string) QueryBuilder
- func (qb QueryBuilder) Queries(events Resolver) (queries []Query)
- func (q QueryBuilder) QueryValues(d *Desc) []map[string]string
- func (q QueryBuilder) Scan() QueryBuilder
- func (q QueryBuilder) Values() QueryBuilder
- func (q QueryBuilder) Where(label string, value ...string) QueryBuilder
- type QueryMode
- type Queryer
- type Registries
- type Registry
- type Resetable
- type Resolution
- func (r Resolution) AddSteps(t time.Time, n int) time.Time
- func (r Resolution) IsZero() bool
- func (r Resolution) MarshalTime(t time.Time) string
- func (r Resolution) Name() string
- func (r Resolution) Round(t time.Time) time.Time
- func (r Resolution) Step() time.Duration
- func (r Resolution) TTL() time.Duration
- func (r Resolution) TimeSequence(s, e time.Time) []time.Time
- func (r Resolution) UnmarshalTime(s string) (t time.Time, err error)
- func (r Resolution) WithCodec(codec tcodec.TimeCodec) Resolution
- func (r Resolution) WithLayout(layout string) Resolution
- func (r Resolution) WithName(name string) Resolution
- func (r Resolution) WithStep(step time.Duration) Resolution
- func (r Resolution) WithTTL(ttl time.Duration) Resolution
- type Resolver
- type ResolverFunc
- type Result
- type Results
- type ScanQuery
- type ScanResult
Constants ¶
View Source
const ( QueryParamEvent = "event" QueryParamResolution = "res" QueryParamStart = "start" QueryParamEnd = "end" QueryParamGroup = "group" QueryParamMode = "mode" )
View Source
const ( // DailyDateFormat is the date format used by the start/end query parameters DailyDateFormat string = "2006-01-02" HourlyDateFormat string = "2006-01-02-15" MinlyDateFormat string = "2006-01-02-15-04" )
View Source
const ( Minly = time.Minute Hourly = time.Hour Daily = 24 * time.Hour Weekly = 7 * Daily Monthly = 30 * Daily Yearly = 365 * Daily )
View Source
const DefaultKeyPrefix = "meter"
View Source
const FieldTerminator = '\x1e'
View Source
const LabelSeparator = '\x1f'
View Source
const NilByte byte = 0
Variables ¶
View Source
var ( ErrInvalidEventLabel = errors.New("Invalid event label") ErrInvalidGroupLabel = errors.New("Invalid group label") ErrInvalidResolution = errors.New("Invalid event resolution") )
View Source
var ( ErrDuplicateEvent = errors.New("Duplicate event registration.") ErrNilRegistry = errors.New("Registry is nil") ErrNilEvent = errors.New("Event is nil") ErrNilDesc = errors.New("Desc is nil") ErrUnregisteredEvent = errors.New("Unregistered event") )
View Source
var ( // NoResolution = Resolution{"totals", 0, 0, NoResolutionCodec} ResolutionHourly = Resolution{"hourly", 0, Hourly, tcodec.LayoutCodec(HourlyDateFormat)} ResolutionDaily = Resolution{"daily", 0, Daily, tcodec.LayoutCodec(DailyDateFormat)} ResolutionMinly = Resolution{"minly", 0, Minly, tcodec.LayoutCodec(MinlyDateFormat)} ResolutionWeekly = Resolution{"weekly", 0, Weekly, tcodec.ISOWeekCodec} )
Functions ¶
func AppendField ¶ added in v0.2.0
func AppendMatch ¶ added in v0.2.0
func AppendMatchField ¶ added in v0.2.0
func CollectResults ¶ added in v0.2.2
func CollectResults(scan <-chan ScanResult) <-chan Results
func MatchField ¶ added in v0.2.3
func QueryPermutations ¶ added in v0.2.0
Types ¶
type Controller ¶
type Controller struct { Q Queryer Events Resolver TimeDecoder tcodec.TimeDecoder }
func (*Controller) ServeHTTP ¶
func (c *Controller) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Counters ¶
type Counters struct {
// contains filtered or unexported fields
}
func NewCounters ¶
func NewCounters() *Counters
func (*Counters) WithLabelValues ¶ added in v0.2.0
type DB ¶
type DB struct { Redis redis.UniversalClient KeyPrefix string }
func NewDB ¶
func NewDB(r redis.UniversalClient) *DB
func (*DB) ExactQuery ¶ added in v0.2.0
func (db *DB) ExactQuery(results chan<- ScanResult, q Query) error
type DataPoint ¶
type DataPoint struct {
Timestamp, Value int64
}
func (DataPoint) MarshalJSON ¶
func (*DataPoint) UnmarshalJSON ¶ added in v0.2.0
type DataPoints ¶ added in v0.2.0
type DataPoints []DataPoint
func (DataPoints) Len ¶ added in v0.2.0
func (s DataPoints) Len() int
func (DataPoints) Less ¶ added in v0.2.0
func (s DataPoints) Less(i, j int) bool
func (DataPoints) MarshalJSON ¶ added in v0.2.0
func (s DataPoints) MarshalJSON() (data []byte, err error)
func (DataPoints) Sort ¶ added in v0.2.0
func (s DataPoints) Sort()
func (DataPoints) Swap ¶ added in v0.2.0
func (s DataPoints) Swap(i, j int)
type Desc ¶ added in v0.2.0
type Desc struct {
// contains filtered or unexported fields
}
func NewCounterDesc ¶ added in v0.2.0
func NewCounterDesc(name string, labels []string, res ...Resolution) *Desc
func NewDesc ¶ added in v0.2.0
func NewDesc(t MetricType, name string, labels []string, res ...Resolution) *Desc
func NewValueDesc ¶ added in v0.2.0
func NewValueDesc(name string, labels []string, res ...Resolution) *Desc
func (*Desc) LabelIndex ¶ added in v0.2.0
func (*Desc) LabelValues ¶ added in v0.2.0
func (d *Desc) LabelValues(values []string) LabelValues
func (*Desc) MatchingQueries ¶ added in v0.2.0
func (*Desc) Resolution ¶ added in v0.2.0
func (d *Desc) Resolution(name string) (r Resolution, ok bool)
func (*Desc) Resolutions ¶ added in v0.2.0
func (d *Desc) Resolutions() []Resolution
func (*Desc) Type ¶ added in v0.2.0
func (d *Desc) Type() MetricType
type Descriptor ¶ added in v0.2.0
type Descriptor interface {
Describe() *Desc
}
type Event ¶
type Event interface { WithLabels(labels LabelValues) Counter WithLabelValues(values ...string) Counter Descriptor Collector }
type FrequencyMap ¶ added in v0.2.0
type LabelValues ¶ added in v0.2.0
func FieldLabels ¶ added in v0.2.2
func FieldLabels(field []string) LabelValues
func (LabelValues) Equal ¶ added in v0.2.0
func (values LabelValues) Equal(other LabelValues) bool
func (LabelValues) Values ¶ added in v0.2.0
func (values LabelValues) Values(labels []string) []string
type Metric ¶ added in v0.2.0
type Metric interface { Counter Descriptor }
type MetricType ¶ added in v0.2.0
type MetricType uint8
const ( MetricTypeIncrement MetricType // Increment value on store MetricTypeUpdateOnce // Update value once on store MetricTypeUpdate // Update value on store )
type Query ¶
type Query struct { Mode QueryMode Event Descriptor Start, End time.Time Group []string Values []map[string]string Resolution Resolution // contains filtered or unexported fields }
type QueryBuilder ¶ added in v0.2.0
type QueryBuilder struct { Mode QueryMode Events []string Start, End time.Time Group []string Query url.Values Resolution string }
func NewQueryBuilder ¶ added in v0.2.0
func NewQueryBuilder() QueryBuilder
func ParseQuery ¶ added in v0.2.0
func ParseQuery(q url.Values, tdec tcodec.TimeDecoder) (s QueryBuilder, err error)
func (QueryBuilder) At ¶ added in v0.2.0
func (q QueryBuilder) At(res Resolution) QueryBuilder
func (QueryBuilder) Between ¶ added in v0.2.0
func (q QueryBuilder) Between(start, end time.Time) QueryBuilder
func (QueryBuilder) Exact ¶ added in v0.2.0
func (q QueryBuilder) Exact() QueryBuilder
func (QueryBuilder) From ¶ added in v0.2.0
func (q QueryBuilder) From(event ...string) QueryBuilder
func (QueryBuilder) GroupBy ¶ added in v0.2.0
func (q QueryBuilder) GroupBy(label ...string) QueryBuilder
func (QueryBuilder) Queries ¶ added in v0.2.0
func (qb QueryBuilder) Queries(events Resolver) (queries []Query)
func (QueryBuilder) QueryValues ¶ added in v0.2.0
func (q QueryBuilder) QueryValues(d *Desc) []map[string]string
func (QueryBuilder) Scan ¶ added in v0.3.0
func (q QueryBuilder) Scan() QueryBuilder
func (QueryBuilder) Values ¶ added in v0.3.0
func (q QueryBuilder) Values() QueryBuilder
func (QueryBuilder) Where ¶ added in v0.2.0
func (q QueryBuilder) Where(label string, value ...string) QueryBuilder
type Registries ¶ added in v0.2.0
type Registries []*Registry
func (Registries) Get ¶ added in v0.2.0
func (r Registries) Get(name string) Event
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) MustRegister ¶
type Resolution ¶
type Resolution struct {
// contains filtered or unexported fields
}
func NewResolution ¶
func NewResolution(name string, step, ttl time.Duration) Resolution
func (Resolution) IsZero ¶ added in v0.2.0
func (r Resolution) IsZero() bool
func (Resolution) MarshalTime ¶
func (r Resolution) MarshalTime(t time.Time) string
func (Resolution) Name ¶
func (r Resolution) Name() string
func (Resolution) Step ¶
func (r Resolution) Step() time.Duration
func (Resolution) TTL ¶
func (r Resolution) TTL() time.Duration
func (Resolution) TimeSequence ¶
func (r Resolution) TimeSequence(s, e time.Time) []time.Time
func (Resolution) UnmarshalTime ¶
func (r Resolution) UnmarshalTime(s string) (t time.Time, err error)
func (Resolution) WithCodec ¶ added in v0.2.0
func (r Resolution) WithCodec(codec tcodec.TimeCodec) Resolution
func (Resolution) WithLayout ¶ added in v0.2.0
func (r Resolution) WithLayout(layout string) Resolution
func (Resolution) WithName ¶ added in v0.2.0
func (r Resolution) WithName(name string) Resolution
func (Resolution) WithStep ¶ added in v0.2.0
func (r Resolution) WithStep(step time.Duration) Resolution
func (Resolution) WithTTL ¶
func (r Resolution) WithTTL(ttl time.Duration) Resolution
type ResolverFunc ¶ added in v0.3.0
func (ResolverFunc) Get ¶ added in v0.3.0
func (rf ResolverFunc) Get(eventName string) Event
type Result ¶
type Result struct { Event string Labels LabelValues Data DataPoints }
type Results ¶ added in v0.2.0
type Results []Result
func (Results) Find ¶ added in v0.2.0
func (s Results) Find(event string, values LabelValues) *Result
func (Results) FrequencyMap ¶ added in v0.2.3
func (s Results) FrequencyMap() FrequencyMap
type ScanQuery ¶ added in v0.2.3
type ScanQuery struct { Mode QueryMode Event *Desc Start, End time.Time Group []string Resolution Resolution Values []LabelValues // contains filtered or unexported fields }
type ScanResult ¶ added in v0.2.0
type ScanResult struct { Event string Group []string Time time.Time Values LabelValues // contains filtered or unexported fields }
func (ScanResult) AppendTo ¶ added in v0.2.3
func (r ScanResult) AppendTo(results Results) Results
Source Files ¶
Click to show internal directories.
Click to hide internal directories.