tophat

package module
v0.0.0-...-92b2fef Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2015 License: MIT Imports: 9 Imported by: 0

README

tophat

web scale

Documentation

Index

Constants

View Source
const SEP = ":"

Variables

View Source
var AggregateHash = `` /* 1088-byte string literal not displayed */
View Source
var DefaultMetric = MetricType{
	Script: redis.NewScript(1, AggregateHash),
}
View Source
var TimestepDay = &Timestep{
	Name:     "day",
	Key:      "d",
	Period:   Day,
	Keep:     2,
	NumSteps: 24,
}

hourly for a day

View Source
var TimestepHour = &Timestep{
	Name:     "hour",
	Key:      "h",
	Period:   Hour,
	Keep:     2,
	NumSteps: 60,
}

define some default normal steps hourly data with minute steps

View Source
var TimestepMonth = &Timestep{
	Name:     "month",
	Key:      "m",
	Period:   Month,
	Keep:     2,
	NumSteps: 30,
}

daily for a month

View Source
var TimestepYear = &Timestep{
	Name:     "year",
	Key:      "y",
	Period:   Year,
	Keep:     2,
	NumSteps: 12,
}

monthly for a year

Functions

func AggregateHashPick

func AggregateHashPick(data AggregateHashData, fn MetricFn) float64

func ByteMap

func ByteMap(result interface{}, err error) (map[string][]byte, error)

lifted from the redis helper StringMap ByteMap is a helper that converts an array of strings (alternating key, value) into a map[string][]byte. The HGETALL and CONFIG GET commands return replies in this format. Requires an even number of values in result.

Types

type AggregateHashData

type AggregateHashData struct {
	Count uint32
	Sum   float64
	Min   float64
	Max   float64
}

func AggregateHashUnpack

func AggregateHashUnpack(data []byte) (AggregateHashData, error)

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(pool *redis.Pool) (*Client, error)

func (*Client) AddMetric

func (c *Client) AddMetric(m *Metric) error

func (*Client) AddTimestep

func (c *Client) AddTimestep(t *Timestep) error

func (*Client) Graph

func (c *Client) Graph(mgr MetricGraphRequest) (*MetricGraph, error)

func (*Client) GraphEachTag

func (c *Client) GraphEachTag(mgr MetricGraphRequest, tag string, tag_values []string) ([]*MetricGraph, error)

func (*Client) Write

func (c *Client) Write(mv MetricValue) error

type Metric

type Metric struct {
	Name  string
	Key   string
	Tags  []string
	Steps []*Timestep
	Type  MetricType
}

func (*Metric) Graph

func (m *Metric) Graph(conn redis.Conn, mgr MetricGraphRequest) (*MetricGraph, error)

func (*Metric) WriteFloat

func (m *Metric) WriteFloat(conn redis.Conn, mv MetricValue) error

type MetricFn

type MetricFn int
const (
	CountFn MetricFn = iota
	SumFn
	MinFn
	MaxFn
	AvgFn
)

type MetricGraph

type MetricGraph struct {
	Tags   map[string]string `json:"tags"`
	Values [][2]float64      `json:"values"`
}

func (*MetricGraph) Spark

func (mg *MetricGraph) Spark() []float64

func (*MetricGraph) SparkString

func (mg *MetricGraph) SparkString() string

type MetricGraphRequest

type MetricGraphRequest struct {
	MetricName string
	TagValues  []string
	Step       *Timestep
	Fn         MetricFn
	FillZero   bool
	NumSteps   int // optional to override Timestep defined steps
}

type MetricType

type MetricType struct {
	Script *redis.Script
}

type MetricValue

type MetricValue struct {
	MetricName string
	TagValues  []string
	Timestamp  time.Time
	ValueFloat float64
}

type Time

type Time int
const (
	Minute Time = iota
	Hour
	Day
	Month
	Year
)

type Timestep

type Timestep struct {
	Name     string
	Key      string
	Period   Time
	Keep     int
	NumSteps int
}

func (*Timestep) PeriodExpireAt

func (t *Timestep) PeriodExpireAt(ts time.Time) int64

func (*Timestep) PeriodStep

func (t *Timestep) PeriodStep(ts time.Time) int

func (*Timestep) PeriodStepList

func (t *Timestep) PeriodStepList(ts time.Time, override int) []int64

func (*Timestep) StartOfPeriod

func (t *Timestep) StartOfPeriod(ts time.Time) int64

func (*Timestep) StartOfPreviousPeriod

func (t *Timestep) StartOfPreviousPeriod(ts time.Time) int64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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