topology

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PodName    = "$pod"
	Service    = "$service"
	Namespace  = "$namespace"
	Container  = "$container"
	Cluster    = "$cluster"
	ReplicaSet = "$replicaset"
	Deployment = "$deployment"
)
View Source
const DefaultMetricTickerPeriod = 15 * time.Second
View Source
const DefaultOffset = 0 * time.Minute
View Source
const DefaultPeriod = 60 * time.Minute

Variables

View Source
var (
	// ADJECTIVES ...
	ADJECTIVES = []string{"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark", "summer",
		"icy", "delicate", "quiet", "white", "cool", "spring", "winter", "patient",
		"twilight", "dawn", "crimson", "wispy", "weathered", "blue", "billowing",
		"broken", "cold", "damp", "falling", "frosty", "green", "long", "late", "lingering",
		"bold", "little", "morning", "muddy", "old", "red", "rough", "still", "small",
		"sparkling", "throbbing", "shy", "wandering", "withered", "wild", "black",
		"young", "holy", "solitary", "fragrant", "aged", "snowy", "proud", "floral",
		"restless", "divine", "polished", "ancient", "purple", "lively", "nameless"}

	// NOUNS ...
	NOUNS = []string{"waterfall", "river", "breeze", "moon", "rain", "wind", "sea", "morning",
		"snow", "lake", "sunset", "pine", "shadow", "leaf", "dawn", "glitter", "forest",
		"hill", "cloud", "meadow", "sun", "glade", "bird", "brook", "butterfly",
		"bush", "dew", "dust", "field", "fire", "flower", "firefly", "feather", "grass",
		"haze", "mountain", "night", "pond", "darkness", "snowflake", "silence",
		"sound", "sky", "shape", "surf", "thunder", "violet", "water", "wildflower",
		"wave", "water", "resonance", "sun", "wood", "dream", "cherry", "tree", "fog",
		"frost", "voice", "paper", "frog", "smoke", "star"}

	VERBS = []string{"run", "jump", "sing", "dance", "write", "read", "swim", "paint", "cook", "eat", "sleep",
		"drive", "talk", "listen", "think", "play", "study", "work", "laugh", "cry", "climb", "fly", "build", "plant",
		"create", "design", "calculate", "solve", "program", "code", "investigate", "explore", "imagine", "craft",
		"sew", "draw", "sculpt", "sing", "type", "analyze", "communicate", "collaborate", "travel", "relax",
		"meditate", "exercise", "hike", "capture", "invent", "inspire"}

	ADVERBS = []string{"quickly", "slowly", "quietly", "loudly", "carefully", "boldly", "cautiously", "anxiously",
		"happily", "sadly", "bravely", "eagerly", "gently", "roughly", "softly", "smoothly", "suddenly", "gradually",
		"frequently", "rarely", "always", "never", "shortly", "longingly", "mysteriously", "calmly", "nervously", "honestly",
		"deftly", "warily", "warmly", "coolly", "effortlessly", "clumsily", "politely", "impolitely", "seriously",
		"playfully", "steadily", "vigorously", "sloppily", "painstakingly", "regularly", "unusually", "seldom", "eventually",
		"readily", "reluctantly", "accidentally", "intentionally", "quickly"}
)

Functions

func AverageValue

func AverageValue(_ float64) float64

func SawtoothValue

func SawtoothValue(phase float64) float64

func SineValue

func SineValue(phase float64) float64

func SquareValue

func SquareValue(phase float64) float64

func TriangleValue

func TriangleValue(phase float64) float64

Types

type Call

type Call struct {
	Service string `json:"service" yaml:"service"`
	Route   string `json:"route" yaml:"route"`
}

type Config

type Config struct {
	Kubernetes *KubernetesConfig
}

type EmbeddedWeight

type EmbeddedWeight struct {
	Weight float64 `json:"weight" yaml:"weight"`
}

func (EmbeddedWeight) GetWeight

func (w EmbeddedWeight) GetWeight() float64

type File

type File struct {
	Topology   *Topology          `json:"topology" yaml:"topology"`
	Flags      []flags.FlagConfig `json:"flags" yaml:"flags"`
	RootRoutes []RootRoute        `json:"rootRoutes" yaml:"rootRoutes"`
	Config     *Config            `json:"config" yaml:"config"`
}

func (*File) ValidateRootRoutes

func (file *File) ValidateRootRoutes() error

type Generator

type Generator interface {
	GenerateKey() string
	GenerateValue() string
}

type Kubernetes

type Kubernetes struct {
	ClusterName string   `json:"cluster_name" yaml:"cluster_name"`
	Request     Resource `json:"request" yaml:"request"`
	Limit       Resource `json:"limit" yaml:"limit"`
	Usage       Usage    `json:"usage" yaml:"usage"`
	Restart     Restart  `json:"restart" yaml:"restart"`
	PodCount    int      `json:"pod_count" yaml:"pod_count"`
	Deployment  string   `json:"deployment" yaml:"deployment"`

	ReplicaSetName string
	Service        string
	Namespace      string

	Cfg *Config
	// contains filtered or unexported fields
}

func (*Kubernetes) CreatePods

func (k *Kubernetes) CreatePods(serviceName string)

func (*Kubernetes) GenerateMetrics

func (k *Kubernetes) GenerateMetrics() []Metric

func (*Kubernetes) GetK8sTags

func (k *Kubernetes) GetK8sTags(pod *Pod) map[string]string

func (*Kubernetes) GetPodCount

func (k *Kubernetes) GetPodCount() int

func (*Kubernetes) GetRandomK8sTags added in v0.14.0

func (k *Kubernetes) GetRandomK8sTags() map[string]string

only called from tag generator!

func (*Kubernetes) RestartDurationWithJitter

func (k *Kubernetes) RestartDurationWithJitter() time.Duration

type KubernetesConfig

type KubernetesConfig struct {
	PodCount int `json:"pod_count" yaml:"pod_count"`
}

type LatencyConfigs

type LatencyConfigs []*LatencyPercentiles

func (*LatencyConfigs) Sample

func (lcfg *LatencyConfigs) Sample(traceID pcommon.TraceID) int64

type LatencyPercentiles

type LatencyPercentiles struct {
	P0Cfg   string `json:"p0" yaml:"p0"`
	P50Cfg  string `json:"p50" yaml:"p50"`
	P95Cfg  string `json:"p95" yaml:"p95"`
	P99Cfg  string `json:"p99" yaml:"p99"`
	P999Cfg string `json:"p99.9" yaml:"p99.9"`
	P100Cfg string `json:"p100" yaml:"p100"`

	EmbeddedWeight      `json:",inline" yaml:",inline"`
	flags.EmbeddedFlags `json:",inline" yaml:",inline"`
	// contains filtered or unexported fields
}

func (*LatencyPercentiles) Sample

func (l *LatencyPercentiles) Sample() int64

type Metric

type Metric struct {
	Name                string            `json:"name" yaml:"name"`
	Type                string            `json:"type" yaml:"type"`
	Min                 float64           `json:"min" yaml:"min"`
	Max                 float64           `json:"max" yaml:"max"`
	Period              *time.Duration    `json:"period" yaml:"period"`
	Offset              *time.Duration    `json:"offset" yaml:"offset"`
	Shape               Shape             `json:"shape" yaml:"shape"`
	ShapeInterface      ShapeInterface    `json:"-" yaml:"-"`
	Tags                map[string]string `json:"tags" yaml:"tags"`
	TagGenerator        TagGenerator      `json:"tagGenerator,omitempty" yaml:"tagGenerator,omitempty"`
	Jitter              float64           `json:"jitter" yaml:"jitter"`
	flags.EmbeddedFlags `json:",inline" yaml:",inline"`
	Pod                 *Pod
	Random              *rand.Rand
}

func (*Metric) GetTags

func (m *Metric) GetTags() map[string]string

func (*Metric) GetValue

func (m *Metric) GetValue() float64

func (*Metric) InitMetric

func (m *Metric) InitMetric()

type Pickable

type Pickable interface {
	GetWeight() float64
	ShouldGenerate() bool
}

type Pod

type Pod struct {
	StartTime       time.Time
	RestartDuration time.Duration
	PodName         string
	Container       string
	Kubernetes      *Kubernetes
}

func (*Pod) ReplaceTags

func (p *Pod) ReplaceTags(tags map[string]string) map[string]string

func (*Pod) RestartIfNeeded

func (p *Pod) RestartIfNeeded(flags flags.EmbeddedFlags, logger *zap.Logger) bool

type RandomTagGenerator added in v0.14.0

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

func (*RandomTagGenerator) GenerateKey added in v0.14.0

func (rtg *RandomTagGenerator) GenerateKey() string

func (*RandomTagGenerator) GenerateValue added in v0.14.0

func (rtg *RandomTagGenerator) GenerateValue() string

type Resource

type Resource struct {
	CPU    float64 `json:"cpu" yaml:"cpu"`
	Memory float64 `json:"memory" yaml:"memory"`
}

type ResourceAttributeSet

type ResourceAttributeSet struct {
	Kubernetes          *Kubernetes `json:"kubernetes" yaml:"kubernetes"`
	ResourceAttributes  TagMap      `json:"resourceAttrs,omitempty" yaml:"resourceAttrs,omitempty"`
	EmbeddedWeight      `json:",inline" yaml:",inline"`
	flags.EmbeddedFlags `json:",inline" yaml:",inline"`
}

func (*ResourceAttributeSet) GetAttributes

func (r *ResourceAttributeSet) GetAttributes() *TagMap

type ResourceUsage

type ResourceUsage struct {
	Target float64 `json:"target" yaml:"target"`
	Jitter float64 `json:"jitter" yaml:"jitter"`
}

type Restart

type Restart struct {
	Every  time.Duration `json:"every" yaml:"every"`
	Jitter time.Duration `json:"jitter" yaml:"jitter"`
}

type RootRoute

type RootRoute struct {
	Service             string `json:"service" yaml:"service"`
	Route               string `json:"route" yaml:"route"`
	TracesPerHour       int    `json:"tracesPerHour" yaml:"tracesPerHour"`
	flags.EmbeddedFlags `json:",inline" yaml:",inline"`
}

type ServiceRoute

type ServiceRoute struct {
	Route               string         `json:"route" yaml:"route"`
	DownstreamCalls     []Call         `json:"downstreamCalls,omitempty" yaml:"downstreamCalls,omitempty"`
	MaxLatencyMillis    int64          `json:"maxLatencyMillis" yaml:"maxLatencyMillis"`
	LatencyConfigs      LatencyConfigs `json:"latencyConfigs" yaml:"latencyConfigs"`
	TagSets             []TagSet       `json:"tagSets" yaml:"tagSets"`
	flags.EmbeddedFlags `json:",inline" yaml:",inline"`
}

func (*ServiceRoute) SampleLatency

func (r *ServiceRoute) SampleLatency(traceID pcommon.TraceID) int64

type ServiceTier

type ServiceTier struct {
	ServiceName           string
	Routes                map[string]*ServiceRoute `json:"routes" yaml:"routes"`
	TagSets               []TagSet                 `json:"tagSets" yaml:"tagSets"`
	ResourceAttributeSets []ResourceAttributeSet   `json:"resourceAttrSets" yaml:"resourceAttrSets"`
	Metrics               []Metric                 `json:"metrics" yaml:"metrics"`
}

func (*ServiceTier) GetResourceAttributeSet

func (st *ServiceTier) GetResourceAttributeSet(traceID pcommon.TraceID) ResourceAttributeSet

func (*ServiceTier) GetRoute

func (st *ServiceTier) GetRoute(routeName string) *ServiceRoute

func (*ServiceTier) GetTagSet

func (st *ServiceTier) GetTagSet(routeName string, traceID pcommon.TraceID) TagSet

func (*ServiceTier) Validate

func (st *ServiceTier) Validate(topology Topology) error

type Shape

type Shape string
const (
	Sine     Shape = "sine"
	Sawtooth Shape = "sawtooth"
	Square   Shape = "square"
	Triangle Shape = "triangle"
	Average  Shape = "average"
	Leaking  Shape = "leaking"
)

type ShapeInterface

type ShapeInterface interface {
	GetValue(phase float64) float64
}

type TagGenerator

type TagGenerator struct {
	// NumTags is used to generate a random tag set if Tags is empty
	NumTags int `json:"numTags,omitempty" yaml:"numTags,omitempty"`
	NumVals int `json:"numVals,omitempty" yaml:"numVals,omitempty"`
	// Tags is hardcoded tags for this generator. eg - you may want a couple tags "foo,bar" with 5 values each.
	// If Tags is non-empty, NumTags is ignored
	Tags             []string `json:"tags,omitempty" yaml:"tags,omitempty"`
	ValueVariability int      `json:"valueVariability,omitempty" yaml:"valueVariability,omitempty"`
	Random           *rand.Rand
	// contains filtered or unexported fields
}

func (*TagGenerator) GetRefreshedTags added in v0.14.0

func (t *TagGenerator) GetRefreshedTags() map[string]string

func (*TagGenerator) GetTags added in v0.14.0

func (t *TagGenerator) GetTags() map[string]string

func (*TagGenerator) Init added in v0.14.0

func (t *TagGenerator) Init(random *rand.Rand)

type TagMap

type TagMap map[string]interface{}

func (*TagMap) InsertTags

func (tm *TagMap) InsertTags(attr *pcommon.Map)

type TagSet

type TagSet struct {
	Tags                TagMap            `json:"tags,omitempty" yaml:"tags,omitempty"`
	TagGenerators       []TagGenerator    `json:"tagGenerators,omitempty" yaml:"tagGenerators,omitempty"`
	Inherit             []string          `json:"inherit,omitempty" yaml:"inherit,omitempty"`
	CsvTags             map[string]string `json:"csv_tags,omitempty" yaml:"csv_tags,omitempty"`
	EmbeddedWeight      `json:",inline" yaml:",inline"`
	flags.EmbeddedFlags `json:",inline" yaml:",inline"`
}

type Topology

type Topology struct {
	Services map[string]*ServiceTier `json:"services" yaml:"services"`
}

func (*Topology) GetServiceTier

func (t *Topology) GetServiceTier(serviceName string) *ServiceTier

func (*Topology) Load

func (t *Topology) Load() error

func (*Topology) ValidateServiceGraph

func (t *Topology) ValidateServiceGraph(rootRoutes []RootRoute) error

type Usage

type Usage struct {
	CPU     ResourceUsage `json:"cpu" yaml:"cpu"`
	Memory  ResourceUsage `json:"memory" yaml:"memory"`
	Disk    ResourceUsage `json:"disk" yaml:"disk"`
	Network ResourceUsage `json:"network" yaml:"network"`
}

Jump to

Keyboard shortcuts

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