snap

package
v0.0.0-...-b44688a 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: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CaffeInferenceCollector is a name of the snap plugin binary
	CaffeInferenceCollector = "snap-plugin-collector-caffe-inference"
	// DockerCollector is name of snap plugin binary.
	DockerCollector = "snap-plugin-collector-docker"
	// MutilateCollector is name of snap plugin binary.
	MutilateCollector string = "snap-plugin-collector-mutilate"
	// RDTCollector is Snap RDT Metric collector
	RDTCollector = "snap-plugin-collector-rdt"
	// SPECjbbCollector is name of snap plugin binary used to collect metrics from SPECjbb output file.
	SPECjbbCollector string = "snap-plugin-collector-specjbb"
	// USECollector is name of snap plugin binary for the Utilization Saturation and Errors (USE) Method.
	USECollector string = "snap-plugin-collector-use"

	// CassandraPublisher is name of snap plugin binary.
	CassandraPublisher = "snap-plugin-publisher-cassandra"

	// InfluxDBPublisher is name of snap plugin binary.
	InfluxDBPublisher = "snap-plugin-publisher-influxdb"

	// FilePublisher is Snap testing file publisher
	FilePublisher = "snap-plugin-publisher-file"
	// SessionPublisher is name of snap plugin binary.
	SessionPublisher = "snap-plugin-publisher-session-test"
)
View Source
const (
	// PluginAnyVersion identifies any version of plugin that can be passed to Snap API.
	PluginAnyVersion = -1
)

Variables

View Source
var (
	// SnapteldAddress represents snap daemon address flag.
	SnapteldAddress = conf.NewStringFlag("snapteld_address", "Snapteld address in `http://%s:%s` format", "http://127.0.0.1:8181")
)
View Source
var UseSnapSessionForWorkloads = conf.NewBoolFlag(
	"use_snap_with_workloads",
	"Collect Application Performance Metrics for workloads.",
	true)

UseSnapSessionForWorkloads is flag enabling APM collection in workloads.

Functions

func GetPluginNameAndType

func GetPluginNameAndType(filename string) (name string, pluginType string, err error)

GetPluginNameAndType takes plugin binary name like "snap-plugin-collector-mutilate" and returns it's name and type inferred from binary name. Name must conform convention "*snap-plugin-(type)-(name)"

func LoadPlugins

func LoadPlugins(plugins ...string) error

LoadPlugins loads plugins given as input parameter.

Types

type CollectNodeConfigItem

type CollectNodeConfigItem struct {
	Ns    string
	Key   string
	Value interface{}
}

CollectNodeConfigItem represents ConfigItem in CollectWorkflowMapNode.

type Handle

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

Handle is handle for Snap task.

func (*Handle) Address

func (s *Handle) Address() string

Address returns snapteld address.

func (*Handle) EraseOutput

func (s *Handle) EraseOutput() error

EraseOutput does nothing for snap tasks.

func (*Handle) ExitCode

func (s *Handle) ExitCode() (int, error)

ExitCode returns -1 when snap task is disabled because of errors or not terminated. Returns '0' when task is ended.

func (*Handle) Status

func (s *Handle) Status() executor.TaskState

Status checks if Snap task is running.

func (*Handle) StderrFile

func (s *Handle) StderrFile() (*os.File, error)

StderrFile returns error for snap handles.

func (*Handle) StdoutFile

func (s *Handle) StdoutFile() (*os.File, error)

StdoutFile returns error for snap handles.

func (*Handle) Stop

func (s *Handle) Stop() error

Stop blocks and stops Snap task. When task is already stopped or ended, then it will immediately return.

func (*Handle) String

func (s *Handle) String() string

String returns name of snap task.

func (*Handle) Wait

func (s *Handle) Wait(timeout time.Duration) (bool, error)

Wait blocks until the Snap task is executed at least once (including hits that happened in the past).

type PluginLoader

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

PluginLoader is used to simplify Snap plugin loading.

func NewDefaultPluginLoader

func NewDefaultPluginLoader() (*PluginLoader, error)

NewDefaultPluginLoader returns PluginLoader with DefaultPluginLoaderConfig. Returns error when could not connect to Snap.

func NewPluginLoader

func NewPluginLoader(config PluginLoaderConfig) (*PluginLoader, error)

NewPluginLoader constructs PluginLoader with given config. Returns error when could not connect to Snap.

func (PluginLoader) Load

func (l PluginLoader) Load(plugins ...string) error

Load loads supplied plugin names from plugin path and returns slice of encountered errors.

type PluginLoaderConfig

type PluginLoaderConfig struct {
	SnapteldAddress string
}

PluginLoaderConfig contains configuration for PluginLoader.

func DefaultPluginLoaderConfig

func DefaultPluginLoaderConfig() PluginLoaderConfig

DefaultPluginLoaderConfig returns default config for PluginLoader.

type Plugins

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

Plugins provides a 'manager' like abstraction for plugin operations.

func NewPlugins

func NewPlugins(pClient *client.Client) *Plugins

NewPlugins returns an instantiated Plugins object, using pClient for all plugin operations.

func (*Plugins) IsLoaded

func (p *Plugins) IsLoaded(t string, name string) (bool, error)

IsLoaded connects to snap and looks for plugin with given name. Be aware that the name is not the plugin binary path or name but defined by the plugin itself.

func (*Plugins) LoadPlugin

func (p *Plugins) LoadPlugin(pluginPath string) error

LoadPlugin loads plugin binary from path.

func (*Plugins) Unload

func (p *Plugins) Unload(t string, name string, version int) error

Unload unloads a plugin of type t and given name and version.

type Session

type Session struct {
	// TaskName is name of task in Snap.
	TaskName string

	// Metrics to tag in session.
	Metrics []string

	// Tags to be applied to metrics.
	Tags map[string]interface{}

	// CollectNodeConfigItems represent ConfigItems for CollectNode.
	CollectNodeConfigItems []CollectNodeConfigItem

	// Publisher for tagged metrics.
	Publisher *wmap.PublishWorkflowMapNode
	// contains filtered or unexported fields
}

Session provides construct for tagging metrics for a specified time span defined by Start() and Stop().

func NewSession

func NewSession(
	taskName string,
	metrics []string,
	interval time.Duration,
	pClient *client.Client,
	publisher *wmap.PublishWorkflowMapNode,
	tags map[string]interface{}) *Session

NewSession generates a session with a name and a list of metrics to tag. The interval cannot be less than second granularity.

func NewSessionLauncher

func NewSessionLauncher(config SessionConfig) (*Session, error)

NewSessionLauncher construct snap.Session based on provied config It also try load plugins mentioned in config.Plugins and can fails if plugins are unavailable.

func (*Session) Launch

func (s *Session) Launch() (executor.TaskHandle, error)

Launch starts Snap task.

type SessionConfig

type SessionConfig struct {
	SnapteldAddress string
	Publisher       *wmap.PublishWorkflowMapNode
	Interval        time.Duration
	Plugins         []string
	TaskName        string
	Metrics         []string
	Tags            map[string]interface{}
}

SessionConfig holds configuration for snap session

type Tags

type Tags map[string]interface{}

Tags is a structure containing tags for metrics gathering.

Directories

Path Synopsis
sessions
rdt
use

Jump to

Keyboard shortcuts

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