metricdb

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package metricdb handles the storage for metrics.

Design

The db file name is metric and its key-value design in leveldb is:

Key:   <Name>:<Stamp>
Value: <Value>:<Score>:<Average>

For less disk usage:

1. Metric stamps will be converted to 36-hex strings before they are put to db.

2. Metric stamps will minus a "stamp horizon" before they are converted to string.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when requested data not found.
	ErrNotFound = errors.New("metricdb: not found")
	// ErrCorrupted is returned when corrupted data found.
	ErrCorrupted = errors.New("metricdb: corrupted data found")
	// ErrStampTooSmall is returned when stamp is smaller than horizon.
	ErrStampTooSmall = errors.New("metricdb: stamp is too small")
)

Functions

func Horizon

func Horizon() uint32

Horizon returns the timestamp horizon

Types

type DB

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

DB handles metrics storage.

func Open

func Open(fileName string) (*DB, error)

Open a DB by fileName.

func (*DB) Close

func (db *DB) Close() error

Close the DB.

func (*DB) Delete

func (db *DB) Delete(name string, start, end uint32) (int, error)

Delete metrics in a timestamp range, the range is left open and right closed.

func (*DB) DeleteTo

func (db *DB) DeleteTo(name string, end uint32) (int, error)

DeleteTo deletes metrics ranging to a stamp by name.

func (*DB) Get

func (db *DB) Get(name string, start, end uint32) ([]*models.Metric, error)

Get metrics in a timestamp range, the range is left open and right closed.

func (*DB) Put

func (db *DB) Put(m *models.Metric) error

Put a metric into db.

Jump to

Keyboard shortcuts

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