models

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2018 License: Apache-2.0 Imports: 8 Imported by: 88

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LookbackDelta = time.Minute

LookbackDelta determines the time since the last sample after which a time series is considered stale (inclusive). TODO: Make this configurable

Functions

This section is empty.

Types

type Bounds added in v0.4.4

type Bounds struct {
	Start    time.Time
	Duration time.Duration
	StepSize time.Duration
}

Bounds are the time bounds, start time is inclusive but end is exclusive

func (Bounds) Blocks added in v0.4.4

func (b Bounds) Blocks(t time.Time) int

Blocks returns the number of blocks until time t

func (Bounds) Contains added in v0.4.4

func (b Bounds) Contains(t time.Time) bool

Contains returns whether the time lies between the bounds.

func (Bounds) End added in v0.4.4

func (b Bounds) End() time.Time

End calculates the end time for the block and is exclusive

func (Bounds) Equals added in v0.4.4

func (b Bounds) Equals(other Bounds) bool

Equals is true if two bounds are equal, including stepsize

func (Bounds) Nearest added in v0.4.4

func (b Bounds) Nearest(t time.Time) Bounds

Nearest returns the nearest bound before the given time

func (Bounds) Next added in v0.4.4

func (b Bounds) Next(n int) Bounds

Next returns the nth next bound from the current bound

func (Bounds) Previous added in v0.4.4

func (b Bounds) Previous(n int) Bounds

Previous returns the nth previous bound from the current bound

func (Bounds) Steps added in v0.4.4

func (b Bounds) Steps() int

Steps calculates the number of steps for the bounds

func (Bounds) String added in v0.4.4

func (b Bounds) String() string

String representation of the bounds

func (Bounds) TimeForIndex added in v0.4.4

func (b Bounds) TimeForIndex(idx int) (time.Time, error)

TimeForIndex returns the start time for a given index assuming a uniform step size

type MatchType

type MatchType int

MatchType is an enum for label matching types.

const (
	MatchEqual MatchType = iota
	MatchNotEqual
	MatchRegexp
	MatchNotRegexp
)

Possible MatchTypes.

func (MatchType) String

func (m MatchType) String() string

type Matcher

type Matcher struct {
	Type  MatchType `json:"type"`
	Name  []byte    `json:"name"`
	Value []byte    `json:"value"`
	// contains filtered or unexported fields
}

Matcher models the matching of a label. NB: when serialized to JSON, name and value will be in base64.

func NewMatcher

func NewMatcher(t MatchType, n, v []byte) (Matcher, error)

NewMatcher returns a matcher object.

func (Matcher) Matches

func (m Matcher) Matches(s []byte) bool

Matches returns whether the matcher matches the given string value.

func (Matcher) String

func (m Matcher) String() string

type Matchers

type Matchers []Matcher

Matchers is a list of individual matchers.

func (Matchers) String added in v0.4.8

func (m Matchers) String() string

func (Matchers) ToTags

func (m Matchers) ToTags(
	tagOptions TagOptions,
) (Tags, error)

ToTags converts Matchers to Tags NB (braskin): this only works for exact matches

type Metric

type Metric struct {
	ID   string
	Tags Tags
}

Metric is the individual metric that gets returned from the search endpoint.

type Metrics

type Metrics []Metric

Metrics is a list of individual metrics.

type RequestParams

type RequestParams struct {
	Start time.Time
	End   time.Time
	// Now captures the current time and fixes it throughout the request, we may let people override it in the future
	Now        time.Time
	Timeout    time.Duration
	Step       time.Duration
	Query      string
	Debug      bool
	IncludeEnd bool
}

RequestParams represents the params from the request

func (RequestParams) ExclusiveEnd added in v0.4.1

func (r RequestParams) ExclusiveEnd() time.Time

ExclusiveEnd returns the end exclusive

type Tag added in v0.4.2

type Tag struct {
	Name  []byte
	Value []byte
}

Tag is a key/value metric tag pair.

func (Tag) Clone added in v0.4.8

func (t Tag) Clone() Tag

Clone returns a copy of the tag.

func (Tag) String added in v0.4.8

func (t Tag) String() string

type TagOptions added in v0.4.8

type TagOptions interface {
	// Validate validates these tag options.
	Validate() error

	// SetMetricName sets the name for the `metric name` metric.
	SetMetricName(metricName []byte) TagOptions

	// MetricName gets the name for the `metric name `metric`.
	MetricName() []byte
}

TagOptions describes additional options for tags.

func NewTagOptions added in v0.4.8

func NewTagOptions() TagOptions

NewTagOptions builds a new tag options with default values.

type Tags

type Tags struct {
	Opts TagOptions
	Tags []Tag
}

Tags represents a set of tags with options.

func EmptyTags added in v0.4.2

func EmptyTags() Tags

EmptyTags returns empty tags with a default tag options.

func NewTags added in v0.4.8

func NewTags(size int, opts TagOptions) Tags

NewTags builds a tags with the given size and tag options.

func (Tags) Add added in v0.4.2

func (t Tags) Add(other Tags) Tags

Add is used to add two tag structures and maintain sorted order.

func (Tags) AddOrUpdateTag added in v0.4.8

func (t Tags) AddOrUpdateTag(tag Tag) Tags

AddOrUpdateTag is used to add a single tag and maintain sorted order, or to replace the value of an existing tag.

func (Tags) AddTag added in v0.4.3

func (t Tags) AddTag(tag Tag) Tags

AddTag is used to add a single tag and maintain sorted order.

func (Tags) AddTags added in v0.4.8

func (t Tags) AddTags(tags []Tag) Tags

AddTags is used to add a list of tags and maintain sorted order.

func (Tags) Clone added in v0.4.3

func (t Tags) Clone() Tags

Clone returns a copy of the tags.

func (Tags) Get added in v0.4.2

func (t Tags) Get(key []byte) ([]byte, bool)

Get returns the value for the tag with the given name.

func (Tags) ID

func (t Tags) ID() string

ID returns a string representation of the tags.

func (Tags) IDLen added in v0.4.6

func (t Tags) IDLen() int

IDLen returns the length of the ID that would be generated from the tags.

func (Tags) IDMarshalTo added in v0.4.6

func (t Tags) IDMarshalTo(b []byte) []byte

IDMarshalTo writes out the ID representation of the tags into the provided buffer.

func (Tags) IDWithExcludes

func (t Tags) IDWithExcludes(excludeKeys ...[]byte) uint64

IDWithExcludes returns a string representation of the tags excluding some tag keys.

func (Tags) IDWithKeys

func (t Tags) IDWithKeys(includeKeys ...[]byte) uint64

IDWithKeys returns a string representation of the tags only including the given keys.

func (Tags) Len added in v0.4.2

func (t Tags) Len() int

func (Tags) Less added in v0.4.2

func (t Tags) Less(i, j int) bool

func (Tags) Name added in v0.4.8

func (t Tags) Name() ([]byte, bool)

Name gets the metric name.

func (Tags) Normalize added in v0.4.8

func (t Tags) Normalize() Tags

Normalize normalizes the tags by sorting them in place. In future, it might also ensure other things slike uniqueness.

func (Tags) SetName added in v0.4.8

func (t Tags) SetName(value []byte) Tags

SetName sets the metric name.

func (Tags) Swap added in v0.4.2

func (t Tags) Swap(i, j int)

func (Tags) TagsWithKeys added in v0.4.2

func (t Tags) TagsWithKeys(includeKeys [][]byte) Tags

TagsWithKeys returns only the tags which have the given keys.

func (Tags) TagsWithoutKeys added in v0.4.2

func (t Tags) TagsWithoutKeys(excludeKeys [][]byte) Tags

TagsWithoutKeys returns only the tags which do not have the given keys.

func (Tags) WithoutName

func (t Tags) WithoutName() Tags

WithoutName copies the tags excluding the name tag.

Jump to

Keyboard shortcuts

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