tags

package
v0.0.0-...-dc45894 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 10 Imported by: 0

Documentation

Overview

Package tags implements an ipfs-cluster informer publishes user-defined tags as metrics.

Index

Constants

View Source
const (
	DefaultMetricTTL = 30 * time.Second
)

Default values for tags Config

Variables

View Source
var (
	DefaultTags = map[string]string{
		"group": "default",
	}
)

Default values for tags config

View Source
var MetricName = "tags"

MetricName specifies the name of our metric

Functions

This section is empty.

Types

type Config

type Config struct {
	config.Saver

	MetricTTL time.Duration
	Tags      map[string]string
}

Config is used to initialize an Informer and customize the type and parameters of the metric it produces.

func (*Config) ApplyEnvVars

func (cfg *Config) ApplyEnvVars() error

ApplyEnvVars fills in any Config fields found as environment variables.

func (*Config) ConfigKey

func (cfg *Config) ConfigKey() string

ConfigKey returns a human-friendly identifier for this type of Metric.

func (*Config) Default

func (cfg *Config) Default() error

Default initializes this Config with sensible values.

func (*Config) LoadJSON

func (cfg *Config) LoadJSON(raw []byte) error

LoadJSON reads the fields of this Config from a JSON byteslice as generated by ToJSON.

func (*Config) ToDisplayJSON

func (cfg *Config) ToDisplayJSON() ([]byte, error)

ToDisplayJSON returns JSON config as a string.

func (*Config) ToJSON

func (cfg *Config) ToJSON() (raw []byte, err error)

ToJSON generates a JSON-formatted human-friendly representation of this Config.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate checks that the fields of this Config have working values, at least in appearance.

type Informer

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

Informer is a simple object to implement the ipfscluster.Informer and Component interfaces.

func New

func New(cfg *Config) (*Informer, error)

New returns an initialized informer using the given InformerConfig.

func (*Informer) GetMetrics

func (tags *Informer) GetMetrics(ctx context.Context) []api.Metric

GetMetrics returns one metric for each tag defined in the configuration. The metric name is set as "tags:<tag_name>". When no tags are defined, a single invalid metric is returned.

func (*Informer) Name

func (tags *Informer) Name() string

Name returns the name of this informer. Note the informer issues metrics with custom names.

func (*Informer) SetClient

func (tags *Informer) SetClient(c *rpc.Client)

SetClient provides us with an rpc.Client which allows contacting other components in the cluster.

func (*Informer) Shutdown

func (tags *Informer) Shutdown(ctx context.Context) error

Shutdown is called on cluster shutdown. We just invalidate any metrics from this point.

Jump to

Keyboard shortcuts

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