Skip to content
This repository has been archived by the owner on Aug 30, 2019. It is now read-only.

Commit

Permalink
Add config param
Browse files Browse the repository at this point in the history
  • Loading branch information
bmermet committed May 7, 2018
1 parent cf647fe commit 9800336
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmd/trace-agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (a *Agent) Process(t model.Trace) {
// All traces should go through either through the normal score sampler or
// the one dedicated to errors
samplers := make([]*Sampler, 0, 2)
if traceContainsError(t) {
if !a.conf.DisableDedicatedErrorsSampling && traceContainsError(t) {
samplers = append(samplers, a.ErrorsScoreSampler)
} else {
samplers = append(samplers, a.ScoreSampler)
Expand Down
5 changes: 5 additions & 0 deletions config/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ type AgentConfig struct {

// infrastructure agent binary
DDAgentBin string // DDAgentBin will be "" for Agent5 scenarios

// disable the dedicated error sampler
DisableDedicatedErrorsSampling bool
}

// NewDefaultAgentConfig returns a configuration with the default values
Expand Down Expand Up @@ -121,6 +124,8 @@ func NewDefaultAgentConfig() *AgentConfig {

Ignore: make(map[string][]string),
AnalyzedRateByService: make(map[string]float64),

DisableDedicatedErrorsSampling: false,
}
}

Expand Down
2 changes: 2 additions & 0 deletions config/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ func TestUndocumentedYamlConfig(t *testing.T) {
assert.Equal(1.0, agentConfig.AnalyzedRateByService["db"])
assert.Equal(0.9, agentConfig.AnalyzedRateByService["web"])
assert.Equal(0.5, agentConfig.AnalyzedRateByService["index"])
// error sampling
assert.Equal(true, agentConfig.DisableDedicatedErrorsSampling)
}

func TestConfigNewIfExists(t *testing.T) {
Expand Down
5 changes: 5 additions & 0 deletions config/merge_ini.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ func mergeIniConfig(c *AgentConfig, conf *File) error {
c.StatsWriterConfig = readStatsWriterConfig(conf, "trace.writer.stats")
c.TraceWriterConfig = readTraceWriterConfig(conf, "trace.writer.traces")

// undocumented
if v := strings.ToLower(conf.GetDefault("trace.sampler", "disable_dedicated_errors_sampling", "")); v == "yes" || v == "true" {
c.DisableDedicatedErrorsSampling = true
}

return nil
}

Expand Down
24 changes: 14 additions & 10 deletions config/merge_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,17 @@ type proxy struct {
}

type traceAgent struct {
Enabled *bool `yaml:"enabled"`
Endpoint string `yaml:"apm_dd_url"`
Env string `yaml:"env"`
ExtraSampleRate float64 `yaml:"extra_sample_rate"`
MaxTracesPerSecond float64 `yaml:"max_traces_per_second"`
IgnoreResources []string `yaml:"ignore_resources"`
LogFilePath string `yaml:"log_file"`
ReplaceTags []*ReplaceRule `yaml:"replace_tags"`
ReceiverPort int `yaml:"receiver_port"`
APMNonLocalTraffic *bool `yaml:"apm_non_local_traffic"`
Enabled *bool `yaml:"enabled"`
Endpoint string `yaml:"apm_dd_url"`
Env string `yaml:"env"`
ExtraSampleRate float64 `yaml:"extra_sample_rate"`
MaxTracesPerSecond float64 `yaml:"max_traces_per_second"`
DisableDedicatedErrorsSampling bool `yaml:"disable_dedicated_errors_sampling"`
IgnoreResources []string `yaml:"ignore_resources"`
LogFilePath string `yaml:"log_file"`
ReplaceTags []*ReplaceRule `yaml:"replace_tags"`
ReceiverPort int `yaml:"receiver_port"`
APMNonLocalTraffic *bool `yaml:"apm_non_local_traffic"`

WatchdogMaxMemory float64 `yaml:"max_memory"`
WatchdogMaxCPUPct float64 `yaml:"max_cpu_percent"`
Expand Down Expand Up @@ -230,6 +231,9 @@ func mergeYamlConfig(agentConf *AgentConfig, yc *YamlAgentConfig) error {
agentConf.DDAgentBin = yc.TraceAgent.DDAgentBin
}

// undocumented
agentConf.DisableDedicatedErrorsSampling = yc.TraceAgent.DisableDedicatedErrorsSampling

return nil
}

Expand Down
1 change: 1 addition & 0 deletions config/test_cases/undocumented.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ apm_config:
extra_sample_rate: 0.33
max_traces_per_second: 100.0
receiver_port: 25
disable_dedicated_errors_sampling: true
max_cpu_percent: 7
max_connections: 50
max_memory: 30000000
Expand Down

0 comments on commit 9800336

Please sign in to comment.