plugin

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: Apache-2.0 Imports: 3 Imported by: 11

Documentation

Index

Constants

View Source
const (
	NoLimit = 0 // special value indicating no limits (number of instances or tasks)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectContext

type CollectContext interface {
	Context

	// Add concrete metric with calculated value
	AddMetric(namespace string, value interface{}, modifier ...MetricModifier) error

	// Always apply specific modifier(s) for a metrics matching namespace selector
	// Returns object which may be used to dismiss modifiers (make them no-active)
	AlwaysApply(namespaceSelector string, modifier ...MetricModifier) (Dismisser, error)

	// Dismisses all modifiers created by calling AlwaysApply
	DismissAllModifiers()

	// Provide information whether metric or metric group is reasonable to process (won't be filtered).
	ShouldProcess(namespace string) bool

	// List all requested metrics (filter).
	// WARNING: library automatically filters metrics based on provided list. You should use this function
	// in scenarios when output metrics namespaces are constructed based on input list (ie. snmp metrics based on OIDs)
	RequestedMetrics() []string
}

CollectContext provides metric, state and configuration API to be used by custom code.

type Collector

type Collector interface {
	Collect(ctx CollectContext) error
}

type CollectorDefinition

type CollectorDefinition interface {
	Definition

	// Define supported metric, its description and indication if metric is default
	DefineMetric(namespace string, unit string, isDefault bool, description string)

	// Define description for dynamic element
	DefineGroup(name string, description string)

	// Define example config (which will be presented when example task is printed)
	DefineExampleConfig(cfg string) error

	// Allow submitting metrics with namespace not being explicitly defined earlier
	// The only requirement here is that metrics should have matching root namespace element
	// This allows implementing DefineMetric/DefineGroup thus having dynamic metrics but
	// allows some a priori unknown metrics namespaces at the same
	AllowUndefinedMetrics()

	// Allow metrics values not only on leaves but at any namespace level
	AllowValuesAtAnyNamespaceLevel()
}

CollectorDefinition provides API for specifying plugin metadata (supported metrics, descriptions etc)

type Context

type Context interface {
	// Returns configuration value by providing path (representing its position in JSON tree)
	ConfigValue(key string) (string, bool)

	// Returns list of allowed configuration paths
	ConfigKeys() []string

	// Return raw configuration (JSON string)
	RawConfig() []byte

	// Store any object using key to have access from different Collect requests
	Store(key string, value interface{})

	// Load any object using key from different Collect requests (returns an interface{} which need to be casted to concrete type)
	Load(key string) (interface{}, bool)

	// Load any object using key from different Collect requests (passing it to provided reference).
	// Will throw error when dest type doesn't match to type of stored value or object with a given key wasn't found.
	LoadTo(key string, dest interface{}) error

	// Add warning information to current collect / process operation.
	AddWarning(msg string)

	// Return raw context associated with task
	RawContext() context.Context

	// Check if task is completed
	IsDone() bool

	// Check if task is completed (via listening on a channel)
	Done() <-chan struct{}

	// Reference to logger object
	Logger() logrus.FieldLogger
}

CollectContext provides state and configuration API to be used by custom code.

type CustomizableInfoCollector

type CustomizableInfoCollector interface {
	CustomInfo(ctx Context) interface{}
}

type CustomizableInfoPublisher

type CustomizableInfoPublisher interface {
	Publisher
	CustomInfo(ctx Context) interface{}
}

type DefinableCollector

type DefinableCollector interface {
	PluginDefinition(def CollectorDefinition) error
}

type DefinablePublisher

type DefinablePublisher interface {
	Publisher
	PluginDefinition(def PublisherDefinition) error
}

type Definition

type Definition interface {
	// Define maximum number of tasks that one instance of plugin should handle
	DefineTasksPerInstanceLimit(limit int) error

	// Define maximum number of instances
	DefineInstancesLimit(limit int) error
}

Common plugin definition interface

type Dismisser

type Dismisser interface {
	Dismiss()
}

Interface responsible for dismissal of metric modifiers

type InProcessCollector

type InProcessCollector interface {
	Collector
	InProcessPlugin
}

type InProcessPlugin

type InProcessPlugin interface {
	Name() string
	Version() string
}

type InProcessPublisher

type InProcessPublisher interface {
	Publisher
	InProcessPlugin
}

type InProcessStreamingCollector

type InProcessStreamingCollector interface {
	StreamingCollector
	InProcessPlugin
}

type LoadableCollector

type LoadableCollector interface {
	Load(ctx Context) error
}

type LoadablePublisher

type LoadablePublisher interface {
	Publisher
	Load(ctx Context) error
}

type Metric

type Metric interface {
	// Name of metric, ie: [system, cpu, percentage]
	Namespace() Namespace

	// Value associated with measurement
	Value() interface{}

	// Text-like object associated with measurement
	Tags() map[string]string

	// Description of measurement
	Description() string

	// Unit of measurement value
	Unit() string

	// Time, when measurement was taken
	Timestamp() time.Time
}

Representation of AppOptics measurement

type MetricModifier

type MetricModifier interface {
	UpdateMetric(mt MetricSetter)
}

func MetricDescription

func MetricDescription(description string) MetricModifier

func MetricTag

func MetricTag(key string, value string) MetricModifier

func MetricTags

func MetricTags(tags map[string]string) MetricModifier

func MetricTimestamp

func MetricTimestamp(timestamp time.Time) MetricModifier

func MetricUnit

func MetricUnit(unit string) MetricModifier

func RemoveMetricTags

func RemoveMetricTags(tags []string) MetricModifier

type MetricSetter

type MetricSetter interface {
	// Add custom text-like object associated with measurement
	AddTags(map[string]string)

	// Remove tags with given keys
	RemoveTags([]string)

	// Set custom Description of measurement
	SetDescription(string)

	// Set custom unit of measurement value
	SetUnit(string)

	// Set custom timestamp
	SetTimestamp(time.Time)
}

Interface for setting custom metric metadata

type Namespace

type Namespace interface {
	// Return namespace element at the given position
	At(pos int) NamespaceElement

	// Return length of the element
	Len() int

	// True, when metric name contains given element
	HasElement(el string) bool

	// True, when metric name contains element on a given position
	HasElementOn(el string, pos int) bool

	// Name of metric, ie: /system/cpu/percentage
	String() string
}

Representation of AppOptics measurement name

type NamespaceElement

type NamespaceElement interface {
	// Name of element (not empty in case element is dynamic)
	Name() string

	// Value of element (not empty in case element is dynamic)
	Value() string

	// Description associated with element (not empty in case element is dynamic)
	Description() string

	// True, if element is dynamic
	IsDynamic() bool
}

Representation of part of AppOptics measurement name

type Options

type Options struct {
	PluginIP          string
	GRPCPort          int
	GRPCPingTimeout   time.Duration
	GRPCPingMaxMissed uint

	EnableTLS         bool // GRPC Server
	TLSServerCertPath string
	TLSServerKeyPath  string
	TLSClientCAPath   string

	LogLevel          logrus.Level
	EnableProfiling   bool
	PProfPort         int  `json:",omitempty"`
	EnableStats       bool // enable calculation statistics
	EnableStatsServer bool // if true, start statistics HTTP server
	StatsPort         int  `json:",omitempty"`

	UseAPIv2 bool
	AsThread bool

	CollectChunkSize uint64

	PrintExampleTask     bool          `json:"-"`
	DebugMode            bool          `json:"-"`
	PluginConfig         string        `json:"-"`
	PluginFilter         string        `json:"-"`
	DebugCollectCounts   int           `json:"-"`
	DebugCollectInterval time.Duration `json:"-"`
	PrintVersion         bool          `json:"-"`
}

Structure representing plugin configuration (received by parsing command-line arguments) Visit newFlagParser() to find descriptions associated with each option.

type PublishContext

type PublishContext interface {
	Context

	ListAllMetrics() []Metric
	Count() int
}

type Publisher

type Publisher interface {
	Publish(ctx PublishContext) error
}

type PublisherDefinition

type PublisherDefinition interface {
	Definition

	// Define example config (which will be presented when example task is printed)
	DefineExampleConfig(cfg string) error
}

PublisherDefinition provides API for specifying plugin (publisher) metadata (supported metrics, descriptions etc)

type StreamingCollector

type StreamingCollector interface {
	StreamingCollect(ctx CollectContext) error
}

type UnloadableCollector

type UnloadableCollector interface {
	Unload(ctx Context) error
}

type UnloadablePublisher

type UnloadablePublisher interface {
	Publisher
	Unload(ctx Context) error
}

Jump to

Keyboard shortcuts

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