simulator

package
v0.0.0-...-9e5ecb5 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTagsDef

func NewTagsDef(rnd *rand.Rand, namePrefix, valuePrefix string, maxTags int, maxCount int) tagsDef

Types

type Configuration

type Configuration struct {
	// total machines count
	Machines int
	// group machines by clusters.
	// machine in every cluster will drain unique tags from cluster private set of possible tags
	Clusters int
	// number of tags that will be assigned to every machine
	// value will be unique to machine
	GlobalTags int
	// unique tags are tags assigned per machine
	ClusterTags int
	// minimun tags
	MinimumTags int
	// Total metrics
	MetricsTotal int
	// Set of base metrics that reported by all machines
	BaseMetrics int
	// Maximum metrics per machine
	MaxMetrics int
	// Metrics per namespace
	MetricsPerNamespace int
	// Tags per metric
	TagsPerMetric int
	// TagValuesPerMetricTag configures how deiverse values of metric tags.
	TagValuesPerMetricTag int
	// StartSplay configures how far machines start time could drift away from startTime
	StartSplay int
}

Configuration keeps simulation configuration

func NewConfiguration

func NewConfiguration(machines int, metrics int, clusters int) Configuration

type Machine

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

Machine struct keeps state of simulated machine, including timeseries and metadata

func NewMachine

func NewMachine(name string, tags Tags, initialTs uint64, expectedTimeseries int) *Machine

NewMachine creates Machine with specified tags and initial timestamp.

func (*Machine) AddTimeseries

func (m *Machine) AddTimeseries(ns string, name string, gen generator.Generator, period uint64)

AddTimeseries adds timeseries with generator and period.

func (*Machine) AddTimeseriesWithTags

func (m *Machine) AddTimeseriesWithTags(
	ns string, name string, tags Tags, gen generator.Generator, period uint64)

AddTimeseriesWithTags adds timeseries with series specific tags with generator and period.

func (*Machine) Tick

func (m *Machine) Tick(timestamp uint64) *[]TaggedPoints

Tick advance time for machine. Machine generates all metrics up to provided timestamp. Returns tagged points for every timeseries.

type Simulator

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

Simulator keeps state of simulation.

func NewSimulator

func NewSimulator(rnd *rand.Rand, conf Configuration, startTime uint64) *Simulator

func (*Simulator) Run

func (s *Simulator) Run(shard int, shardCount int, runTo int64, cb func(points *[]TaggedPoints))

Run simulator for specified runFor time uints (whatever you use timestamp for, usually seconds) Callback will get tagged points usable to be sent to monitoring systems

type Tag

type Tag struct {
	Name  string
	Value string
}

Tag is piece of metadata attached to every Point

type TaggedPoints

type TaggedPoints struct {
	Namespace  *string
	MetricName *string
	Tags       *Tags
	Datapoints *[]generator.Point
}

TaggedPoints structure hold points with attached Tags

type Tags

type Tags []Tag

Tags is for sorting here.

func (*Tags) FormatSeparated

func (tags *Tags) FormatSeparated(separator rune) string

FormatSeparated builds string from tags: tag=value<separator>tag=value...

func (*Tags) Len

func (tags *Tags) Len() int

func (*Tags) Less

func (tags *Tags) Less(i int, j int) bool

func (*Tags) Swap

func (tags *Tags) Swap(i int, j int)

type TimeSeries

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

TimeSeries keeps track on timestamps and operate on generator to create new points.

func (*TimeSeries) Tick

func (ts *TimeSeries) Tick(timestamp uint64) (*TaggedPoints, bool)

Tick advaces single timeseries to timestamp, generating points in between last timestamp and new

Jump to

Keyboard shortcuts

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