config

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config interface {
	// RegisterReloadCallback takes a name and a function that will be called
	// when the configuration is reloaded. This will happen infrequently. If
	// consumers of configuration set config values on startup, they should
	// check their values haven't changed and re-start anything that needs
	// restarting with the new values.
	RegisterReloadCallback(callback func())

	// GetListenAddr returns the address and port on which to listen for
	// incoming events
	GetListenAddr() (string, error)

	// GetPeerListenAddr returns the address and port on which to listen for
	// peer traffic
	GetPeerListenAddr() (string, error)

	// GetAPIKeys returns a list of Honeycomb API keys
	GetAPIKeys() ([]string, error)

	// GetPeers returns a list of other servers participating in this proxy cluster
	GetPeers() ([]string, error)

	GetPeerManagementType() (string, error)

	// GetRedisHost returns the address of a Redis instance to use for peer
	// management.
	GetRedisHost() (string, error)

	// GetHoneycombAPI returns the base URL (protocol, hostname, and port) of
	// the upstream Honeycomb API server
	GetHoneycombAPI() (string, error)

	// GetLoggingLevel returns the verbosity with which we should log
	GetLoggingLevel() (string, error)

	// GetSendDelay returns the number of seconds to pause after a trace is
	// complete before sending it, to allow stragglers to arrive
	GetSendDelay() (time.Duration, error)

	// GetTraceTimeout is how long to wait before sending a trace even if it's
	// not complete. This should be longer than the longest expected trace
	// duration.
	GetTraceTimeout() (time.Duration, error)

	// GetOtherConfig attempts to fill the passed in struct with the contents of
	// a subsection of the config.   This is used by optional configurations to
	// allow different implementations of necessary interfaces configure
	// themselves
	GetOtherConfig(name string, configStruct interface{}) error

	// GetLoggerType returns the type of the logger to use. Valid types are in
	// the logger package
	GetLoggerType() (string, error)

	// GetHoneycombLoggerConfig returns the config specific to the HoneycombLogger
	GetHoneycombLoggerConfig() (HoneycombLoggerConfig, error)

	// GetCollectorType returns the type of the collector to use. Valid types
	// are in the collect package
	GetCollectorType() (string, error)

	// GetInMemCollectorCacheCapacity returns the config specific to the InMemCollector
	GetInMemCollectorCacheCapacity() (InMemoryCollectorCacheCapacity, error)

	// GetSamplerConfigForDataset returns the sampler type to use for the given dataset
	GetSamplerConfigForDataset(string) (interface{}, error)

	// GetMetricsType returns the type of metrics to use. Valid types are in the
	// metrics package
	GetMetricsType() (string, error)

	// GetHoneycombMetricsConfig returns the config specific to HoneycombMetrics
	GetHoneycombMetricsConfig() (HoneycombMetricsConfig, error)

	// GetPrometheusMetricsConfig returns the config specific to PrometheusMetrics
	GetPrometheusMetricsConfig() (PrometheusMetricsConfig, error)

	// GetUpstreamBufferSize returns the size of the libhoney buffer to use for the upstream
	// libhoney client
	GetUpstreamBufferSize() int
	// GetPeerBufferSize returns the size of the libhoney buffer to use for the peer forwarding
	// libhoney client
	GetPeerBufferSize() int

	GetIdentifierInterfaceName() (string, error)

	GetUseIPV6Identifier() (bool, error)

	GetRedisIdentifier() (string, error)

	// GetSendTickerValue returns the duration to use to check for traces to send
	GetSendTickerValue() time.Duration

	// GetDebugServiceAddr sets the IP and port the debug service will run on (you must provide the
	// command line flag -d to start the debug service)
	GetDebugServiceAddr() (string, error)

	GetIsDryRun() bool
}

func NewConfig added in v0.8.0

func NewConfig(config, rules string) (Config, error)

NewConfig creates a new config struct

type DeterministicSamplerConfig added in v0.10.0

type DeterministicSamplerConfig struct {
	SampleRate int
}

type DynamicSamplerConfig added in v0.10.0

type DynamicSamplerConfig struct {
	SampleRate                   int64
	ClearFrequencySec            int64
	FieldList                    []string
	UseTraceLength               bool
	AddSampleRateKeyToTrace      bool
	AddSampleRateKeyToTraceField string
}

type EMADynamicSamplerConfig added in v0.10.0

type EMADynamicSamplerConfig struct {
	GoalSampleRate      int
	AdjustmentInterval  int
	Weight              float64
	AgeOutValue         float64
	BurstMultiple       float64
	BurstDetectionDelay uint
	MaxKeys             int

	FieldList                    []string
	UseTraceLength               bool
	AddSampleRateKeyToTrace      bool
	AddSampleRateKeyToTraceField string
}

type HoneycombLevel added in v0.10.0

type HoneycombLevel int

type HoneycombLoggerConfig added in v0.10.0

type HoneycombLoggerConfig struct {
	LoggerHoneycombAPI string `validate:"required,url"`
	LoggerAPIKey       string `validate:"required"`
	LoggerDataset      string `validate:"required"`
	Level              HoneycombLevel
}

type HoneycombMetricsConfig added in v0.10.0

type HoneycombMetricsConfig struct {
	MetricsHoneycombAPI      string `validate:"required,url"`
	MetricsAPIKey            string `validate:"required"`
	MetricsDataset           string `validate:"required"`
	MetricsReportingInterval int64  `validate:"required"`
}

type InMemoryCollectorCacheCapacity added in v0.10.0

type InMemoryCollectorCacheCapacity struct {
	// CacheCapacity must be less than math.MaxInt32
	CacheCapacity int `validate:"required,lt=2147483647"`
	MaxAlloc      uint64
}

type MockConfig

type MockConfig struct {
	Callbacks                            []func()
	GetAPIKeysErr                        error
	GetAPIKeysVal                        []string
	GetCollectorTypeErr                  error
	GetCollectorTypeVal                  string
	GetInMemoryCollectorCacheCapacityErr error
	GetInMemoryCollectorCacheCapacityVal InMemoryCollectorCacheCapacity
	GetHoneycombAPIErr                   error
	GetHoneycombAPIVal                   string
	GetListenAddrErr                     error
	GetListenAddrVal                     string
	GetPeerListenAddrErr                 error
	GetPeerListenAddrVal                 string
	GetLoggerTypeErr                     error
	GetLoggerTypeVal                     string
	GetHoneycombLoggerConfigErr          error
	GetHoneycombLoggerConfigVal          HoneycombLoggerConfig
	GetLoggingLevelErr                   error
	GetLoggingLevelVal                   string
	GetOtherConfigErr                    error
	// GetOtherConfigVal must be a JSON representation of the config struct to be populated.
	GetOtherConfigVal             string
	GetPeersErr                   error
	GetPeersVal                   []string
	GetRedisHostErr               error
	GetRedisHostVal               string
	GetSamplerTypeErr             error
	GetSamplerTypeVal             interface{}
	GetMetricsTypeErr             error
	GetMetricsTypeVal             string
	GetHoneycombMetricsConfigErr  error
	GetHoneycombMetricsConfigVal  HoneycombMetricsConfig
	GetPrometheusMetricsConfigErr error
	GetPrometheusMetricsConfigVal PrometheusMetricsConfig
	GetSendDelayErr               error
	GetSendDelayVal               time.Duration
	GetTraceTimeoutErr            error
	GetTraceTimeoutVal            time.Duration
	GetUpstreamBufferSizeVal      int
	GetPeerBufferSizeVal          int
	SendTickerVal                 time.Duration
	IdentifierInterfaceName       string
	UseIPV6Identifier             bool
	RedisIdentifier               string
	PeerManagementType            string
	DebugServiceAddr              string
	DryRun                        bool

	Mux sync.RWMutex
}

MockConfig will respond with whatever config it's set to do during initialization

func (*MockConfig) GetAPIKeys

func (m *MockConfig) GetAPIKeys() ([]string, error)

func (*MockConfig) GetCollectorType

func (m *MockConfig) GetCollectorType() (string, error)

func (*MockConfig) GetDebugServiceAddr added in v0.9.0

func (m *MockConfig) GetDebugServiceAddr() (string, error)

func (*MockConfig) GetHoneycombAPI

func (m *MockConfig) GetHoneycombAPI() (string, error)

func (*MockConfig) GetHoneycombLoggerConfig added in v0.10.0

func (m *MockConfig) GetHoneycombLoggerConfig() (HoneycombLoggerConfig, error)

func (*MockConfig) GetHoneycombMetricsConfig added in v0.10.0

func (m *MockConfig) GetHoneycombMetricsConfig() (HoneycombMetricsConfig, error)

func (*MockConfig) GetIdentifierInterfaceName added in v0.8.0

func (m *MockConfig) GetIdentifierInterfaceName() (string, error)

func (*MockConfig) GetInMemCollectorCacheCapacity added in v0.10.0

func (m *MockConfig) GetInMemCollectorCacheCapacity() (InMemoryCollectorCacheCapacity, error)

func (*MockConfig) GetIsDryRun added in v0.9.0

func (m *MockConfig) GetIsDryRun() bool

func (*MockConfig) GetListenAddr

func (m *MockConfig) GetListenAddr() (string, error)

func (*MockConfig) GetLoggerType

func (m *MockConfig) GetLoggerType() (string, error)

func (*MockConfig) GetLoggingLevel

func (m *MockConfig) GetLoggingLevel() (string, error)

func (*MockConfig) GetMetricsType

func (m *MockConfig) GetMetricsType() (string, error)

func (*MockConfig) GetOtherConfig

func (m *MockConfig) GetOtherConfig(name string, iface interface{}) error

func (*MockConfig) GetPeerBufferSize

func (m *MockConfig) GetPeerBufferSize() int

func (*MockConfig) GetPeerListenAddr

func (m *MockConfig) GetPeerListenAddr() (string, error)

func (*MockConfig) GetPeerManagementType added in v0.8.0

func (m *MockConfig) GetPeerManagementType() (string, error)

func (*MockConfig) GetPeers

func (m *MockConfig) GetPeers() ([]string, error)

func (*MockConfig) GetPrometheusMetricsConfig added in v0.10.0

func (m *MockConfig) GetPrometheusMetricsConfig() (PrometheusMetricsConfig, error)

func (*MockConfig) GetRedisHost

func (m *MockConfig) GetRedisHost() (string, error)

func (*MockConfig) GetRedisIdentifier added in v0.8.0

func (m *MockConfig) GetRedisIdentifier() (string, error)

func (*MockConfig) GetSamplerConfigForDataset added in v0.10.0

func (m *MockConfig) GetSamplerConfigForDataset(dataset string) (interface{}, error)

TODO: allow per-dataset mock values

func (*MockConfig) GetSendDelay

func (m *MockConfig) GetSendDelay() (time.Duration, error)

func (*MockConfig) GetSendTickerValue added in v0.8.0

func (m *MockConfig) GetSendTickerValue() time.Duration

func (*MockConfig) GetTraceTimeout

func (m *MockConfig) GetTraceTimeout() (time.Duration, error)

func (*MockConfig) GetUpstreamBufferSize

func (m *MockConfig) GetUpstreamBufferSize() int

func (*MockConfig) GetUseIPV6Identifier added in v0.8.0

func (m *MockConfig) GetUseIPV6Identifier() (bool, error)

func (*MockConfig) RegisterReloadCallback

func (m *MockConfig) RegisterReloadCallback(callback func())

func (*MockConfig) ReloadConfig

func (m *MockConfig) ReloadConfig()

type PeerManagementConfig added in v0.10.0

type PeerManagementConfig struct {
	Type                    string   `validate:"required,oneof= file redis"`
	Peers                   []string `validate:"dive,url"`
	RedisHost               string
	IdentifierInterfaceName string
	UseIPV6Identifier       bool
	RedisIdentifier         string
}

type PrometheusMetricsConfig added in v0.10.0

type PrometheusMetricsConfig struct {
	MetricsListenAddr string `validate:"required"`
}

type RulesBasedSamplerCondition added in v0.11.0

type RulesBasedSamplerCondition struct {
	Field    string
	Operator string
	Value    interface{}
}

type RulesBasedSamplerConfig added in v0.11.0

type RulesBasedSamplerConfig struct {
	Rule []*RulesBasedSamplerRule
}

type RulesBasedSamplerRule added in v0.11.0

type RulesBasedSamplerRule struct {
	Name       string
	SampleRate int
	Drop       bool
	Condition  []*RulesBasedSamplerCondition
}

Jump to

Keyboard shortcuts

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