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 ¶
- type Conf
- func WithBackoff(backoff int) Conf
- func WithEndpoint(endpoint string) Conf
- func WithInterval(interval time.Duration) Conf
- func WithLogger(log internal.FieldLogger) Conf
- func WithMapFile(mapFile string) Conf
- func WithName(name string) Conf
- func WithTimeout(timeout time.Duration) Conf
- func WithTypeName(typeName string) Conf
- func WithViper(v unmarshaller, name, key string) Conf
- type Config
- func (c *Config) Backoff() int
- func (c *Config) Endpoint() string
- func (c *Config) Interval() time.Duration
- func (c *Config) Logger() internal.FieldLogger
- func (c *Config) Name() string
- func (c *Config) NewInstance() (reader.DataReader, error)
- func (c *Config) Timeout() time.Duration
- func (c *Config) TypeName() string
- type Reader
- func (r *Reader) Backoff() int
- func (r *Reader) Endpoint() string
- func (r *Reader) Interval() time.Duration
- func (r *Reader) Logger() internal.FieldLogger
- func (r *Reader) Mapper() datatype.Mapper
- func (r *Reader) Name() string
- func (r *Reader) Ping() error
- func (r *Reader) Read(job *token.Context) (*reader.Result, error)
- func (r *Reader) SetBackoff(backoff int)
- func (r *Reader) SetEndpoint(endpoint string)
- func (r *Reader) SetInterval(interval time.Duration)
- func (r *Reader) SetLogger(log internal.FieldLogger)
- func (r *Reader) SetMapper(mapper datatype.Mapper)
- func (r *Reader) SetName(name string)
- func (r *Reader) SetTimeout(timeout time.Duration)
- func (r *Reader) SetTypeName(typeName string)
- func (r *Reader) Timeout() time.Duration
- func (r *Reader) TypeName() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conf ¶ added in v0.9.1
Conf func is used for initializing a Config object.
func WithBackoff ¶ added in v0.9.1
WithBackoff doesn't produce any errors.
func WithEndpoint ¶ added in v0.9.1
WithEndpoint produces an error if endpoint is empty.
func WithInterval ¶ added in v0.9.1
WithInterval doesn't produce any errors.
func WithLogger ¶ added in v0.9.1
func WithLogger(log internal.FieldLogger) Conf
WithLogger produces an error if the log is nil.
func WithMapFile ¶ added in v0.9.1
WithMapFile returns any errors on reading the file. If the mapFile is empty, it does nothing and returns nil.
func WithTimeout ¶ added in v0.9.1
WithTimeout doesn't produce any errors.
func WithTypeName ¶ added in v0.9.1
WithTypeName produces an error if typeName is 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"` // 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 ¶
NewConfig returns an instance of the expvar reader func NewConfig(log internal.FieldLogger, name, typeName string, endpoint, routepath string, interval, timeout time.Duration, backoff int, mapFile string) (*Config, error) {
func (*Config) NewInstance ¶
func (c *Config) NewInstance() (reader.DataReader, error)
NewInstance returns an instance of the expvar reader.
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 | ErrInvalidEndpoint typeName == "" | ErrEmptyTypeName backoff < 5 | ErrLowBackoffValue
func (*Reader) Logger ¶ added in v0.8.1
func (r *Reader) Logger() internal.FieldLogger
Logger returns the log
func (*Reader) Ping ¶ added in v0.7.0
Ping pings the endpoint and return nil if was successful. It returns an ErrEndpointNotAvailable if the endpoint id unavailable.
func (*Reader) Read ¶ added in v0.6.0
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
SetBackoff sets the backoff of the reader
func (*Reader) SetEndpoint ¶ added in v0.8.1
SetEndpoint sets the endpoint of the reader
func (*Reader) SetInterval ¶ added in v0.8.1
SetInterval sets the interval of the reader
func (*Reader) SetLogger ¶ added in v0.8.1
func (r *Reader) SetLogger(log internal.FieldLogger)
SetLogger sets the log of the reader
func (*Reader) SetTimeout ¶ added in v0.8.1
SetTimeout sets the timeout of the reader
func (*Reader) SetTypeName ¶ added in v0.8.1
SetTypeName sets the type name of the reader