Documentation ¶
Index ¶
- Constants
- Variables
- func Alias(s string) string
- func IsTemplateName(name string) bool
- func Join(sep string, parts ...string) string
- func Label(s string) string
- func Log(name string, n int64, labels ...string) error
- func LogEvent(e *Event, n int64, labels ...string)
- func MustLog(name string, n int64, labels ...string)
- func MustPersist(tm time.Time, r *redis.Client)
- func MustRegister(name string, t *Event)
- func NormalizeLabels(labels ...string) (out []string)
- func PermutationPairs(input url.Values) [][]string
- func Persist(tm time.Time, r *redis.Client) error
- func ReadRecords(r redis.UniversalClient, records []*Record) error
- func Register(name string, t *Event) error
- func Replacer(labels ...string) *strings.Replacer
- func SetAlias(label string, aliases ...string)
- func TimeSequence(start time.Time, end time.Time, unit time.Duration) []time.Time
- type Aliases
- type Batch
- type Controller
- type Counter
- type Counters
- type DB
- type DataPoint
- type DateRangeParserFunc
- type Dimension
- type Event
- func (e *Event) AliasedLabels(input []string, aliases Aliases) (labels Labels)
- func (e *Event) AllField() string
- func (e *Event) DimField(dim Dimension, q map[string]string) (field string, ok bool)
- func (e *Event) EventName(labels Labels) string
- func (e *Event) Field(input ...string) string
- func (e *Event) HasLabel(a string) bool
- func (e *Event) Key(res *Resolution, tm time.Time, labels Labels) string
- func (e *Event) Labels(input ...string) (labels []string)
- func (e *Event) Log(n int64, labels ...string)
- func (e *Event) MatchField(group string, input ...string) string
- func (e *Event) MustPersist(tm time.Time, r *redis.Client)
- func (e *Event) Persist(tm time.Time, r *redis.Client) (err error)
- func (e *Event) Record(r *Resolution, t time.Time, labels []string) *Record
- func (e *Event) Records(res *Resolution, start, end time.Time, queries ...[]string) []*Record
- func (e *Event) Snapshot() map[string]int64
- func (e *Event) ValueIndex(label string) int
- type FlushError
- type Labels
- type Logger
- func (lo *Logger) Close()
- func (lo *Logger) FlushErrors() int64
- func (lo *Logger) Log(name string, n int64, labels ...string) error
- func (lo *Logger) MustLog(name string, n int64, labels ...string)
- func (lo *Logger) MustPersist(tm time.Time, r *redis.Client)
- func (lo *Logger) Persist(tm time.Time, r *redis.Client) error
- type Query
- type Record
- type RecordSequence
- type Registry
- type Resolution
- func (r *Resolution) Key(event string, t time.Time) string
- func (r *Resolution) MarshalTime(t time.Time) string
- func (r *Resolution) ParseDateRange(s, e string) (start, end time.Time, err error)
- 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) WithTTL(ttl time.Duration) *Resolution
- type Result
- type Summary
- type SummaryController
- type SummaryQuery
Constants ¶
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 DefaultMaxResults = 10000
View Source
const LabelSeparator = ':'
Variables ¶
View Source
var ( NilEventError = errors.New("Event is nil.") NilResolutionError = errors.New("Resolution is nil.") InvalidEventLabelError = errors.New("Invalid event label.") )
View Source
var ( NoResolution = &Resolution{"totals", 0, 0, NoResolutionCodec} ResolutionHourly = &Resolution{"hourly", 0, Hourly, tc.LayoutCodec(HourlyDateFormat)} ResolutionDaily = &Resolution{"daily", 0, Daily, tc.LayoutCodec(DailyDateFormat)} ResolutionMinly = &Resolution{"minly", 0, Minly, tc.LayoutCodec(MinlyDateFormat)} ResolutionWeekly = &Resolution{"weekly", 0, Weekly, tc.ISOWeekCodec} )
View Source
var (
DuplicateTypeError = errors.New("Duplicate type registration.")
)
View Source
var (
MaxRecordsError = errors.New("Max records reached")
)
View Source
var NoResolutionCodec = tc.NewTimeCodec(func(t time.Time) string { return "*" }, func(s string) (t time.Time, e error) { return })
View Source
var (
UnregisteredEventError = errors.New("Unregistered event type")
)
Functions ¶
func IsTemplateName ¶
func MustRegister ¶
func NormalizeLabels ¶
func PermutationPairs ¶
func ReadRecords ¶
func ReadRecords(r redis.UniversalClient, records []*Record) error
Types ¶
type Controller ¶
type Controller struct { Resolution *Resolution DB *DB MaxRecords int }
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) BatchIncrement ¶
type DB ¶
type DB struct { Aliases Aliases Registry *Registry Redis redis.UniversalClient }
func NewDB ¶
func NewDB(r redis.UniversalClient) *DB
func (*DB) SummaryScan ¶ added in v0.1.11
func (db *DB) SummaryScan(q SummaryQuery) (sum Summary, err error)
type DataPoint ¶
func (*DataPoint) MarshalJSON ¶
type DateRangeParserFunc ¶
func DateRangeParser ¶
func DateRangeParser(dec tc.TimeDecoder) DateRangeParserFunc
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
func (*Event) AliasedLabels ¶
func (*Event) MatchField ¶ added in v0.1.12
MatchField returns a redis MATCH argument with an asterisk matcher on the group label
func (*Event) ValueIndex ¶ added in v0.1.11
type FlushError ¶
func (FlushError) Error ¶
func (e FlushError) Error() string
type Logger ¶
func (*Logger) FlushErrors ¶
type Query ¶
type Record ¶
type Record struct { Name string Time time.Time Key string Field string Labels []string Result *redis.StringCmd }
func (*Record) MarshalJSON ¶
type RecordSequence ¶
type RecordSequence []*Record
func (RecordSequence) Group ¶
func (s RecordSequence) Group() []*Result
func (RecordSequence) Results ¶
func (s RecordSequence) Results() []*Result
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) MustRegister ¶
type Resolution ¶
type Resolution struct { Name string // contains filtered or unexported fields }
func NewResolution ¶
func NewResolution(name string, step, ttl time.Duration) *Resolution
func (*Resolution) MarshalTime ¶
func (r *Resolution) MarshalTime(t time.Time) string
func (*Resolution) ParseDateRange ¶
func (r *Resolution) ParseDateRange(s, e string) (start, end time.Time, err error)
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) WithTTL ¶
func (r *Resolution) WithTTL(ttl time.Duration) *Resolution
type SummaryController ¶ added in v0.1.11
type SummaryController struct { Resolution *Resolution DB *DB }
func (*SummaryController) ServeHTTP ¶ added in v0.1.11
func (c *SummaryController) ServeHTTP(w http.ResponseWriter, r *http.Request)
type SummaryQuery ¶ added in v0.1.11
Click to show internal directories.
Click to hide internal directories.