Documentation
¶
Overview ¶
Package config implements a component to handle agent configuration. This component temporarily wraps pkg/config.
This component initializes pkg/config based on the bundle params, and will return the same results as that package. This is to support migration to a component architecture. When no code still uses pkg/config, that package will be removed.
The mock component does nothing at startup, beginning with an empty config. It also overwrites the pkg/config.Datadog for the duration of the test.
Index ¶
- Constants
- Variables
- func AddOverride(name string, value interface{})
- func AddOverrideFunc(f func(Config))
- func AddOverrides(vars map[string]interface{})
- func ApplyOverrideFuncs(config Config)
- func GetIPCAddress(cfg ConfigReader) (string, error)
- func IsLocalAddress(address string) (string, error)
- func Merge(configPaths []string, cfg Config) error
- func SanitizeAPIKeyConfig(cfg Config, key string)
- type Component
- type Config
- type ConfigLoader
- type ConfigReader
- type ConfigReaderWriter
- type ConfigWriter
- type LogConfig
- type Proxy
- type Warnings
Constants ¶
const ( // DefaultSite is the default site the Agent sends data to. DefaultSite = "datadoghq.com" // DefaultBatchWait is the default HTTP batch wait in second for logs DefaultBatchWait = 5 // DefaultBatchMaxConcurrentSend is the default HTTP batch max concurrent send for logs DefaultBatchMaxConcurrentSend = 0 // DefaultBatchMaxSize is the default HTTP batch max size (maximum number of events in a single batch) for logs DefaultBatchMaxSize = 1000 // DefaultInputChanSize is the default input chan size for events DefaultInputChanSize = 100 // DefaultBatchMaxContentSize is the default HTTP batch max content size (before compression) for logs // It is also the maximum possible size of a single event. Events exceeding this limit are dropped. DefaultBatchMaxContentSize = 5000000 // DefaultLogsSenderBackoffFactor is the default logs sender backoff randomness factor DefaultLogsSenderBackoffFactor = 2.0 // DefaultLogsSenderBackoffBase is the default logs sender base backoff time, seconds DefaultLogsSenderBackoffBase = 1.0 // DefaultLogsSenderBackoffMax is the default logs sender maximum backoff time, seconds DefaultLogsSenderBackoffMax = 120.0 // DefaultLogsSenderBackoffRecoveryInterval is the default logs sender backoff recovery interval DefaultLogsSenderBackoffRecoveryInterval = 2 )
Variables ¶
var ( // StartTime is the agent startup time StartTime = time.Now() )
Variables to initialize at start time
Functions ¶
func AddOverride ¶
func AddOverride(name string, value interface{})
AddOverride provides an externally accessible method for overriding config variables. This method must be called before Load() to be effective.
func AddOverrideFunc ¶
func AddOverrideFunc(f func(Config))
AddOverrideFunc allows to add a custom logic to override configuration. This method must be called before Load() to be effective.
func AddOverrides ¶
func AddOverrides(vars map[string]interface{})
AddOverrides provides an externally accessible method for overriding config variables. This method must be called before Load() to be effective.
func ApplyOverrideFuncs ¶
func ApplyOverrideFuncs(config Config)
ApplyOverrideFuncs calls overrideFuncs
func GetIPCAddress ¶
func GetIPCAddress(cfg ConfigReader) (string, error)
GetIPCAddress returns the IPC address or an error if the address is not local
func IsLocalAddress ¶
IsLocalAddress determines whether it is local address
func SanitizeAPIKeyConfig ¶
SanitizeAPIKeyConfig strips newlines and other control characters from a given key.
Types ¶
type Component ¶
type Component interface {
ConfigReader
// Warnings returns config warnings collected during setup.
Warnings() *Warnings
// Object returns wrapped config
Object() ConfigReader
}
Component is the component type.
type Config ¶
type Config interface {
ConfigReaderWriter
ConfigLoader
}
Config represents an object that can load and store configuration parameters coming from different kind of sources: - defaults - files - environment variables - flags
type ConfigLoader ¶
type ConfigLoader interface {
SetDefault(key string, value interface{})
SetFs(fs afero.Fs)
SetEnvPrefix(in string)
BindEnv(input ...string)
SetEnvKeyReplacer(r *strings.Replacer)
SetEnvKeyTransformer(key string, fn func(string) interface{})
UnmarshalKey(key string, rawVal interface{}, opts ...viper.DecoderConfigOption) error
Unmarshal(rawVal interface{}) error
UnmarshalExact(rawVal interface{}) error
ReadInConfig() error
ReadConfig(in io.Reader) error
MergeConfig(in io.Reader) error
MergeConfigOverride(in io.Reader) error
AddConfigPath(in string)
SetConfigName(in string)
SetConfigFile(in string)
SetConfigType(in string)
BindPFlag(key string, flag *pflag.Flag) error
// SetKnown adds a key to the set of known valid config keys
SetKnown(key string)
// BindEnvAndSetDefault sets the default value for a config parameter and adds an env binding
// in one call, used for most config options.
//
// If env is provided, it will override the name of the environment variable used for this
// config key
BindEnvAndSetDefault(key string, val interface{}, env ...string)
}
type ConfigReader ¶
type ConfigReader interface {
Get(key string) interface{}
GetString(key string) string
GetBool(key string) bool
GetInt(key string) int
GetInt32(key string) int32
GetInt64(key string) int64
GetFloat64(key string) float64
GetTime(key string) time.Time
GetDuration(key string) time.Duration
GetStringSlice(key string) []string
GetFloat64SliceE(key string) ([]float64, error)
GetStringMap(key string) map[string]interface{}
GetStringMapString(key string) map[string]string
GetStringMapStringSlice(key string) map[string][]string
GetSizeInBytes(key string) uint
GetProxies() *Proxy
ConfigFileUsed() string
AllSettings() map[string]interface{}
AllSettingsWithoutDefault() map[string]interface{}
AllKeys() []string
IsSet(key string) bool
// UnmarshalKey Unmarshal a configuration key into a struct
UnmarshalKey(key string, rawVal interface{}, opts ...viper.DecoderConfigOption) error
// IsKnown returns whether this key is known
IsKnown(key string) bool
// GetKnownKeys returns all the keys that meet at least one of these criteria:
// 1) have a default, 2) have an environment variable binded, 3) are an alias or 4) have been SetKnown()
GetKnownKeys() map[string]interface{}
// GetEnvVars returns a list of the env vars that the config supports.
// These have had the EnvPrefix applied, as well as the EnvKeyReplacer.
GetEnvVars() []string
// IsSectionSet checks if a given section is set by checking if any of
// its subkeys is set.
IsSectionSet(section string) bool
// Warnings returns pointer to a list of warnings (completes config.Component interface)
Warnings() *Warnings
// Object returns ConfigReader to config (completes config.Component interface)
Object() ConfigReader
}
ConfigReader is a subset of Config that only allows reading of configuration
type ConfigReaderWriter ¶
type ConfigReaderWriter interface {
ConfigReader
ConfigWriter
}
type ConfigWriter ¶
type LogConfig ¶
type LogConfig ConfigReader