processor

package
v0.0.0-...-21b0101 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package processor contains all routines performing processing on incoming metrics.

Index

Constants

This section is empty.

Variables

View Source
var NewProcessor = func(config *exchange.SystemConfig, memory *exchange.MetricMemory) (Instance, error) {
	processor := DefaultInstance{
		config: config,
		memory: memory,
		stats:  &processorStats{mutex: &sync.RWMutex{}},
	}
	return &processor, nil
}

NewProcessor returns instance of ProcessorInstance referencing SystemConfig and MetricMemory instances given by caller.

Functions

func ParseTime

func ParseTime(str string) (time.Time, error)

ParseTime parses string representation of time as produced by Time.String().

Types

type DefaultInstance

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

DefaultInstance wires together all data elements required to perform metrics processing.

func (*DefaultInstance) Config

func (p *DefaultInstance) Config() *exchange.SystemConfig

Config gets the config referenced by this processor instance

func (*DefaultInstance) DeliverStatus

func (p *DefaultInstance) DeliverStatus() interface{}

DeliverStatus provides a data structure reflecting state of processor part for diagnostic purposes.

func (*DefaultInstance) Memory

func (p *DefaultInstance) Memory() *exchange.MetricMemory

Memory gets the metric memory referenced by this processor instance

func (*DefaultInstance) ProcessMetrics

func (p *DefaultInstance) ProcessMetrics(rawMetrics []plugin.MetricType)

ProcessMetrics initiates a processing run on a batch of metrics. This function engages following locks: - Lock on metric memory (ProcessorInstance.memory), - Lock on processor stats (ProcessorInstance.stats).

type Instance

type Instance interface {
	// Config gets the system config instance referenced by this processor
	Config() *exchange.SystemConfig
	// Memory gets the metric memory instance referenced by this processor
	Memory() *exchange.MetricMemory
	// ProcessMetrics initiates a processing run on a batch of metrics.
	ProcessMetrics(rawMetrics []plugin.MetricType)
	// DeliverStatus provides a data structure reflecting state of
	// processor part for diagnostic purposes.
	DeliverStatus() interface{}
}

Instance wires together all data elements required to perform metrics processing.

type MetricMap

type MetricMap map[string]interface{}

MetricMap is a wrapper around map of metrics (possibly nested) allowing to parse its values into specific types

func (MetricMap) FlattenValues

func (m MetricMap) FlattenValues() MetricMap

FlattenValues returns a new map instance with keys mapping directly to their value, so {a: {value: 5}, b: {value: -1}} becomes {a:5, b:-1}.

func (MetricMap) Get

func (m MetricMap) Get(key string) (interface{}, bool)

Get extracts Data value from metric entry within map

func (MetricMap) GetStr

func (m MetricMap) GetStr(key, defValue string) (string, error)

GetStr parses map entry as instance of string, returning defValue if entry is missing; return error if underlying value is not a string

func (MetricMap) GetTimeFromStr

func (m MetricMap) GetTimeFromStr(key string, defValue time.Time) (time.Time, error)

GetTimeFromStr parses map entry as instance of Time, parsing defValue if value is missing, and returns optional parsing errors.

func (MetricMap) GetUint64

func (m MetricMap) GetUint64(key string, defValue uint64) (uint64, error)

GetUint64 parses map entry as instance of uint64, falls back to default value if entry is missing, and returns optional parsing errors.

Jump to

Keyboard shortcuts

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