expvar

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package expvar contains logic to read from an expvar provide. The data comes in JSON format. The GC and memory related information will be changed to better presented to the data recorders. Bytes will be turned into megabytes, gc lists will be truncated to remove zero values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conf added in v0.9.1

type Conf func(*Config) error

Conf func is used for initializing a Config object.

func WithLogger added in v0.9.1

func WithLogger(log tools.FieldLogger) Conf

WithLogger produces an error if the log is nil.

func WithMapFile added in v0.9.1

func WithMapFile(mapFile string) Conf

WithMapFile returns any errors on reading the file. If the mapFile is empty, it does nothing and returns nil.

func WithViper added in v0.9.1

func WithViper(v unmarshaller, name, key string) Conf

WithViper produces an error any of the inputs are empty.

type Config

type Config struct {
	EXPTypeName  string `mapstructure:"type_name"`
	EXPEndpoint  string `mapstructure:"endpoint"`
	EXPInterval  string `mapstructure:"interval"`
	EXPTimeout   string `mapstructure:"timeout"`
	EXPBackoff   int    `mapstructure:"backoff"`
	MapFile      string `mapstructure:"map_file"`
	EXPName      string
	ConfInterval time.Duration
	ConfTimeout  time.Duration
	// contains filtered or unexported fields
}

Config holds the necessary configuration for setting up an expvar reader endpoint. If MapFile is provided, the data will be mapped, otherwise it uses the DefaultMapper.

func NewConfig

func NewConfig(conf ...Conf) (*Config, error)

NewConfig returns an instance of the expvar reader.

func (*Config) Backoff

func (c *Config) Backoff() int

Backoff returns backoff from the config file.

func (*Config) Endpoint

func (c *Config) Endpoint() string

Endpoint returns endpoint from the config file.

func (*Config) Interval

func (c *Config) Interval() time.Duration

Interval returns interval after reading from the config file.

func (*Config) Logger

func (c *Config) Logger() tools.FieldLogger

Logger returns logger.

func (*Config) Mapper added in v0.9.2

func (c *Config) Mapper() datatype.Mapper

Mapper returns the mapper assigned to this object.

func (*Config) Name

func (c *Config) Name() string

Name returns name from the config file.

func (*Config) Reader added in v0.10.0

func (c *Config) Reader() (reader.DataReader, error)

Reader implements the ReaderConf interface.

func (*Config) Timeout

func (c *Config) Timeout() time.Duration

Timeout returns timeout after reading from the config file.

func (*Config) TypeName added in v0.2.1

func (c *Config) TypeName() string

TypeName returns type name from the config file.

type Reader

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

Reader can read from any application that exposes expvar information. It implements DataReader interface.

func New added in v0.7.0

func New(options ...func(reader.Constructor) error) (*Reader, error)

New generates the Reader based on the provided options. It returns and error on the following occasions:

+------------------+----------------------+
|    Condition     |        Error         |
+------------------+----------------------+
| name == ""       | ErrEmptyName         |
| endpoint == ""   | ErrEmptyEndpoint     |
| Invalid endpoint | InvalidEndpointError |
| typeName == ""   | ErrEmptyTypeName     |
| backoff < 5      | LowBackoffValueError |
+------------------+----------------------+

func (*Reader) Backoff added in v0.8.1

func (r *Reader) Backoff() int

Backoff returns the backoff.

func (*Reader) Endpoint added in v0.8.1

func (r *Reader) Endpoint() string

Endpoint returns the endpoint.

func (*Reader) Interval added in v0.1.1

func (r *Reader) Interval() time.Duration

Interval returns the interval.

func (*Reader) Mapper added in v0.3.0

func (r *Reader) Mapper() datatype.Mapper

Mapper returns the mapper object.

func (*Reader) Name

func (r *Reader) Name() string

Name shows the name identifier for this reader.

func (*Reader) Ping added in v0.7.0

func (r *Reader) Ping() error

Ping pings the endpoint and return nil if was successful. It returns an EndpointNotAvailableError if the endpoint id unavailable.

func (*Reader) Read added in v0.6.0

func (r *Reader) Read(job *token.Context) (*reader.Result, error)

Read begins reading from the target. It returns an error back to the engine if it can't read from metrics provider, Ping() is not called or the endpoint has been unresponsive too many times.

func (*Reader) SetBackoff added in v0.8.1

func (r *Reader) SetBackoff(backoff int)

SetBackoff sets the backoff of the reader.

func (*Reader) SetEndpoint added in v0.8.1

func (r *Reader) SetEndpoint(endpoint string)

SetEndpoint sets the endpoint of the reader.

func (*Reader) SetInterval added in v0.8.1

func (r *Reader) SetInterval(interval time.Duration)

SetInterval sets the interval of the reader.

func (*Reader) SetLogger added in v0.8.1

func (r *Reader) SetLogger(log tools.FieldLogger)

SetLogger sets the log of the reader.

func (*Reader) SetMapper added in v0.8.1

func (r *Reader) SetMapper(mapper datatype.Mapper)

SetMapper sets the mapper of the reader.

func (*Reader) SetName added in v0.8.1

func (r *Reader) SetName(name string)

SetName sets the name of the reader.

func (*Reader) SetTimeout added in v0.8.1

func (r *Reader) SetTimeout(timeout time.Duration)

SetTimeout sets the timeout of the reader.

func (*Reader) SetTypeName added in v0.8.1

func (r *Reader) SetTypeName(typeName string)

SetTypeName sets the type name of the reader.

func (*Reader) Timeout added in v0.1.1

func (r *Reader) Timeout() time.Duration

Timeout returns the time-out.

func (*Reader) TypeName added in v0.2.1

func (r *Reader) TypeName() string

TypeName shows the typeName the recorder should record as.

Jump to

Keyboard shortcuts

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