You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
prometheus/db.go

76 lines
1.4 KiB

// Package tsdb implements a time series storage for float64 sample data.
package tsdb
import (
"encoding/binary"
"sync"
"time"
"github.com/fabxc/tsdb/chunks"
"github.com/prometheus/common/log"
)
// DefaultOptions used for the DB.
var DefaultOptions = &Options{
StalenessDelta: 5 * time.Minute,
}
// Options of the DB storage.
type Options struct {
StalenessDelta time.Duration
}
// DB is a time series storage.
type DB struct {
logger log.Logger
opts *Options
8 years ago
shards map[uint64]*TimeShards
}
// Open or create a new DB.
func Open(path string, l log.Logger, opts *Options) (*DB, error) {
if opts == nil {
opts = DefaultOptions
}
c := &DB{
8 years ago
logger: l,
opts: opts,
}
return c, nil
}
8 years ago
type Label struct {
Name, Value string
}
8 years ago
// LabelSet is a sorted set of labels. Order has to be guaranteed upon
// instantiation.
type LabelSet []Label
8 years ago
func (ls LabelSet) Len() int { return len(ls) }
func (ls LabelSet) Swap(i, j int) { ls[i], ls[j] = ls[j], ls[i]}
func (ls LabelSet) Less(i, j int) bool { return ls[i].Name < ls[j].Name }
8 years ago
// NewLabelSet returns a sorted LabelSet from the given labels.
// The caller has to guarantee that all label names are unique.
func NewLabelSet(ls ...Label) LabelSet {
set := make(LabelSet, 0, len(l))
for _, l := range ls {
set = append(set, l)
}
8 years ago
sort.Sort(set)
8 years ago
return set
}
8 years ago
type Vector struct {
LabelSets []LabelSet
Values []float64
}
8 years ago
func (db *DB) AppendVector(v *Vector) error {
return nil
}