Documentation
¶
Index ¶
- Constants
- Variables
- func Set(config *ini.File)
- type AgentConfig
- type DynamicConfig
- type Enablable
- type File
- func (c *File) Get(section, name string) (string, error)
- func (c *File) GetDefault(section, name string, defaultVal string) string
- func (c *File) GetFloat(section, name string) (float64, error)
- func (c *File) GetInt(section, name string) (int, error)
- func (c *File) GetInt64(section, name string) (int64, error)
- func (c *File) GetSection(key string) (*ini.Section, error)
- func (c *File) GetStrArray(section, name string, sep rune) ([]string, error)
- type HTTPObfuscationConfig
- type JSONObfuscationConfig
- type ObfuscationConfig
- type RateByService
- type ReplaceRule
- type YamlAgentConfig
Constants ¶
const (
// DefaultLogFilePath is where the agent will write logs if not overriden in the conf
DefaultLogFilePath = "/var/log/datadog/trace-agent.log"
)
Variables ¶
var ( // ErrMissingAPIKey is returned when the config could not be validated due to missing API key. ErrMissingAPIKey = errors.New("you must specify an API Key, either via a configuration file or the DD_API_KEY env var") // ErrMissingHostname is returned when the config could not be validated due to missing hostname. ErrMissingHostname = errors.New("failed to automatically set the hostname, you must specify it via configuration for or the DD_HOSTNAME env var") )
Functions ¶
Types ¶
type AgentConfig ¶
type AgentConfig struct {
Enabled bool
// Global
Hostname string
DefaultEnv string // the traces will default to this environment
ConfigPath string // the source of this config, if any
// API
APIEndpoint string
APIKey string `json:"-"` // never publish this
APIEnabled bool
// Concentrator
BucketInterval time.Duration // the size of our pre-aggregation per bucket
ExtraAggregators []string
// Sampler configuration
ExtraSampleRate float64
PreSampleRate float64
MaxTPS float64
// Receiver
ReceiverHost string
ReceiverPort int
ConnectionLimit int // for rate-limiting, how many unique connections to allow in a lease period (30s)
ReceiverTimeout int
// Writers
ServiceWriterConfig writerconfig.ServiceWriterConfig
StatsWriterConfig writerconfig.StatsWriterConfig
TraceWriterConfig writerconfig.TraceWriterConfig
// internal telemetry
StatsdHost string
StatsdPort int
// logging
LogLevel string
LogFilePath string
LogThrottlingEnabled bool
// watchdog
MaxMemory float64 // MaxMemory is the threshold (bytes allocated) above which program panics and exits, to be restarted
MaxCPU float64 // MaxCPU is the max UserAvg CPU the program should consume
MaxConnections int // MaxConnections is the threshold (opened TCP connections) above which program panics and exits, to be restarted
WatchdogInterval time.Duration // WatchdogInterval is the delay between 2 watchdog checks
// http/s proxying
ProxyURL *url.URL
SkipSSLValidation bool
// filtering
Ignore map[string][]string
// ReplaceTags is used to filter out sensitive information from tag values.
// It maps tag keys to a set of replacements. Only supported in A6.
ReplaceTags []*ReplaceRule
// transaction analytics
AnalyzedRateByServiceLegacy map[string]float64
AnalyzedSpansByService map[string]map[string]float64
// infrastructure agent binary
DDAgentBin string // DDAgentBin will be "" for Agent5 scenarios
// Obfuscation holds sensitive data obufscator's configuration.
Obfuscation *ObfuscationConfig
}
AgentConfig handles the interpretation of the configuration (with default behaviors) in one place. It is also a simple structure to share across all the Agent components, with 100% safe and reliable values. It is exposed with expvar, so make sure to exclude any sensible field from JSON encoding. Use New() to create an instance.
func Load ¶
func Load(path string) (*AgentConfig, error)
Load attempts to load the configuration from the given path. If it's not found it returns an error and a default configuration.
func (*AgentConfig) LoadEnv ¶
func (c *AgentConfig) LoadEnv()
LoadEnv reads environment variable values into the config.
func (*AgentConfig) LoadIni ¶
func (c *AgentConfig) LoadIni(path string) error
LoadIni reads the contents of the given INI file into the config.
func (*AgentConfig) LoadYaml ¶
func (c *AgentConfig) LoadYaml(path string) error
LoadYaml reads the contents of the given YAML file into the config.
func (*AgentConfig) Validate ¶
func (c *AgentConfig) Validate() error
Validate validates if the current configuration is good for the agent to start with.
type DynamicConfig ¶
type DynamicConfig struct {
// RateByService contains the rate for each service/env tuple,
// used in priority sampling by client libs.
RateByService RateByService
}
DynamicConfig contains configuration items which may change dynamically over time.
func NewDynamicConfig ¶
func NewDynamicConfig() *DynamicConfig
NewDynamicConfig creates a new dynamic config object.
type Enablable ¶
type Enablable struct {
Enabled bool `yaml:"enabled"`
}
Enablable can represent any option that has an "enabled" boolean sub-field.
type File ¶
type File struct {
Path string
// contains filtered or unexported fields
}
A File is a representation of an ini file with some custom convenience methods.
func Get ¶
func Get() *File
Get returns the currently active global config (the previous config opened via NewFile)
func NewIni ¶
NewIni reads the file in configPath and returns a corresponding *File or an error if encountered. This File is set as the default active config file.
func (*File) Get ¶
Get returns a value from the section/name pair, or an error if it can't be found.
func (*File) GetDefault ¶
GetDefault attempts to get the value in section/name, but returns the default if one is not found.
func (*File) GetFloat ¶
GetFloat gets an float value from section/name, or an error if it is missing or cannot be converted to an float.
func (*File) GetInt ¶
GetInt gets an integer value from section/name, or an error if it is missing or cannot be converted to an integer.
func (*File) GetInt64 ¶
GetInt64 gets a 64-bit integer value from section/name, or an error if it is missing or cannot be converted to an integer.
func (*File) GetSection ¶
GetSection is a convenience method to return an entire section of ini config
type HTTPObfuscationConfig ¶
type HTTPObfuscationConfig struct {
// RemoveQueryStrings determines query strings to be removed from HTTP URLs.
RemoveQueryString bool `yaml:"remove_query_string"`
// RemovePathDigits determines digits in path segments to be obfuscated.
RemovePathDigits bool `yaml:"remove_paths_with_digits"`
}
HTTPObfuscationConfig holds the configuration settings for HTTP obfuscation.
type JSONObfuscationConfig ¶
type JSONObfuscationConfig struct {
// Enabled will specify whether obfuscation should be enabled.
Enabled bool `yaml:"enabled"`
// KeepValues will specify a set of keys for which their values will
// not be obfuscated.
KeepValues []string `yaml:"keep_values"`
}
JSONObfuscationConfig holds the obfuscation configuration for sensitive data found in JSON objects.
type ObfuscationConfig ¶
type ObfuscationConfig struct {
// ES holds the obfuscation configuration for ElasticSearch bodies.
ES JSONObfuscationConfig `yaml:"elasticsearch"`
// Mongo holds the obfuscation configuration for MongoDB queries.
Mongo JSONObfuscationConfig `yaml:"mongodb"`
// HTTP holds the obfuscation settings for HTTP URLs.
HTTP HTTPObfuscationConfig `yaml:"http"`
// RemoveStackTraces specifies whether stack traces should be removed.
// More specifically "error.stack" tag values will be cleared.
RemoveStackTraces bool `yaml:"remove_stack_traces"`
// Redis holds the configuration for obfuscating the "redis.raw_command" tag
// for spans of type "redis".
Redis Enablable `yaml:"redis"`
// Memcached holds the configuration for obfuscating the "memcached.command" tag
// for spans of type "memcached".
Memcached Enablable `yaml:"memcached"`
}
ObfuscationConfig holds the configuration for obfuscating sensitive data for various span types.
type RateByService ¶
type RateByService struct {
// contains filtered or unexported fields
}
RateByService stores the sampling rate per service. It is thread-safe, so one can read/write on it concurrently, using getters and setters.
func (*RateByService) GetAll ¶
func (rbs *RateByService) GetAll() map[string]float64
GetAll returns all sampling rates for all services.
func (*RateByService) SetAll ¶
func (rbs *RateByService) SetAll(rates map[string]float64)
SetAll the sampling rate for all services. If a service/env is not in the map, then the entry is removed.
type ReplaceRule ¶
type ReplaceRule struct {
// Name specifies the name of the tag that the replace rule addresses. However,
// some exceptions apply such as:
// • "resource.name" will target the resource
// • "*" will target all tags and the resource
Name string `yaml:"name"`
// Pattern specifies the regexp pattern to be used when replacing. It must compile.
Pattern string `yaml:"pattern"`
// Re holds the compiled Pattern and is only used internally.
Re *regexp.Regexp `yaml:"-"`
// Repl specifies the replacement string to be used when Pattern matches.
Repl string `yaml:"repl"`
}
type YamlAgentConfig ¶
type YamlAgentConfig struct {
APIKey string `yaml:"api_key"`
HostName string `yaml:"hostname"`
LogLevel string `yaml:"log_level"`
Proxy proxy `yaml:"proxy"`
SkipSSLValidation *bool `yaml:"skip_ssl_validation"`
StatsdPort int `yaml:"dogstatsd_port"`
TraceAgent traceAgent `yaml:"apm_config"`
}
YamlAgentConfig is a structure used for marshaling the datadog.yaml configuration available in Agent versions >= 6
func NewYaml ¶
func NewYaml(configPath string) (*YamlAgentConfig, error)
NewYamlIfExists returns a new YamlAgentConfig if the given configPath is exists.