Skip to content

Commit 54604a1

Browse files
nsrip-ddfelixge
andauthored
profiler, ddtrace/tracer: enable code hotspots & endpoints by default with 100% CPU profiling (#1169)
* profiler: set default CPU profiling interval to match duration After testing this default on many high-volume internal workloads, we've determined this default is safe for production. It's also important for the code hotspots feature to be able to associated as many traces as possible with profiling data. * ddtrace/tracer: enable code hotspots & endpoints by default After testing the feature internally on several high-volume workloads, we've determined this feature can be safely enabled by default for production workloads. Co-authored-by: Felix Geisendörfer <felix@datadoghq.com>
1 parent 24cd31a commit 54604a1

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

ddtrace/tracer/log_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestStartupLog(t *testing.T) {
2626
logStartup(tracer)
2727
lines := removeAppSec(tp.Lines())
2828
assert.Len(lines, 2)
29-
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sampling_rules":null,"sampling_rules_error":"","service_mappings":null,"tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"profiler_code_hotspots_enabled":false,"profiler_endpoints_enabled":false,"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"false","appsec":((true)|(false)),"agent_features":{"DropP0s":false,"Stats":false,"StatsdPort":0}}`, lines[1])
29+
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sampling_rules":null,"sampling_rules_error":"","service_mappings":null,"tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"profiler_code_hotspots_enabled":((false)|(true)),"profiler_endpoints_enabled":((false)|(true)),"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"false","appsec":((true)|(false)),"agent_features":{"DropP0s":false,"Stats":false,"StatsdPort":0}}`, lines[1])
3030
})
3131

3232
t.Run("configured", func(t *testing.T) {
@@ -55,7 +55,7 @@ func TestStartupLog(t *testing.T) {
5555
tp.Reset()
5656
logStartup(tracer)
5757
assert.Len(tp.Lines(), 2)
58-
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"configuredEnv","service":"configured.service","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":true,"analytics_enabled":true,"sample_rate":"0\.123000","sampling_rules":\[{"service":"mysql","name":"","sample_rate":0\.75}\],"sampling_rules_error":"","service_mappings":{"initial_service":"new_service"},"tags":{"runtime-id":"[^"]*","tag":"value","tag2":"NaN"},"runtime_metrics_enabled":true,"health_metrics_enabled":true,"profiler_code_hotspots_enabled":false,"profiler_endpoints_enabled":false,"dd_version":"2.3.4","architecture":"[^"]*","global_service":"configured.service","lambda_mode":"false","appsec":((true)|(false)),"agent_features":{"DropP0s":false,"Stats":false,"StatsdPort":0}}`, tp.Lines()[1])
58+
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"configuredEnv","service":"configured.service","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":true,"analytics_enabled":true,"sample_rate":"0\.123000","sampling_rules":\[{"service":"mysql","name":"","sample_rate":0\.75}\],"sampling_rules_error":"","service_mappings":{"initial_service":"new_service"},"tags":{"runtime-id":"[^"]*","tag":"value","tag2":"NaN"},"runtime_metrics_enabled":true,"health_metrics_enabled":true,"profiler_code_hotspots_enabled":((false)|(true)),"profiler_endpoints_enabled":((false)|(true)),"dd_version":"2.3.4","architecture":"[^"]*","global_service":"configured.service","lambda_mode":"false","appsec":((true)|(false)),"agent_features":{"DropP0s":false,"Stats":false,"StatsdPort":0}}`, tp.Lines()[1])
5959
})
6060

6161
t.Run("errors", func(t *testing.T) {
@@ -69,7 +69,7 @@ func TestStartupLog(t *testing.T) {
6969
tp.Reset()
7070
logStartup(tracer)
7171
assert.Len(tp.Lines(), 2)
72-
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sampling_rules":\[{"service":"some.service","name":"","sample_rate":0\.234}\],"sampling_rules_error":"found errors:\\n\\tat index 1: rate not provided","service_mappings":null,"tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"profiler_code_hotspots_enabled":false,"profiler_endpoints_enabled":false,"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"false","appsec":((true)|(false)),"agent_features":{"DropP0s":false,"Stats":false,"StatsdPort":0}}`, tp.Lines()[1])
72+
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test","agent_url":"http://localhost:9/v0.4/traces","agent_error":"Post .*","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sampling_rules":\[{"service":"some.service","name":"","sample_rate":0\.234}\],"sampling_rules_error":"found errors:\\n\\tat index 1: rate not provided","service_mappings":null,"tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"profiler_code_hotspots_enabled":((false)|(true)),"profiler_endpoints_enabled":((false)|(true)),"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"false","appsec":((true)|(false)),"agent_features":{"DropP0s":false,"Stats":false,"StatsdPort":0}}`, tp.Lines()[1])
7373
})
7474

7575
t.Run("lambda", func(t *testing.T) {
@@ -81,7 +81,7 @@ func TestStartupLog(t *testing.T) {
8181
tp.Reset()
8282
logStartup(tracer)
8383
assert.Len(tp.Lines(), 1)
84-
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test","agent_url":"http://localhost:9/v0.4/traces","agent_error":"","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sampling_rules":null,"sampling_rules_error":"","service_mappings":null,"tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"profiler_code_hotspots_enabled":false,"profiler_endpoints_enabled":false,"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"true","appsec":((true)|(false)),"agent_features":{"DropP0s":false,"Stats":false,"StatsdPort":0}}`, tp.Lines()[0])
84+
assert.Regexp(`Datadog Tracer v[0-9]+\.[0-9]+\.[0-9]+ INFO: DATADOG TRACER CONFIGURATION {"date":"[^"]*","os_name":"[^"]*","os_version":"[^"]*","version":"[^"]*","lang":"Go","lang_version":"[^"]*","env":"","service":"tracer\.test","agent_url":"http://localhost:9/v0.4/traces","agent_error":"","debug":false,"analytics_enabled":false,"sample_rate":"NaN","sampling_rules":null,"sampling_rules_error":"","service_mappings":null,"tags":{"runtime-id":"[^"]*"},"runtime_metrics_enabled":false,"health_metrics_enabled":false,"profiler_code_hotspots_enabled":((false)|(true)),"profiler_endpoints_enabled":((false)|(true)),"dd_version":"","architecture":"[^"]*","global_service":"","lambda_mode":"true","appsec":((true)|(false)),"agent_features":{"DropP0s":false,"Stats":false,"StatsdPort":0}}`, tp.Lines()[0])
8585
})
8686
}
8787

ddtrace/tracer/option.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,8 @@ func newConfig(opts ...StartOption) *config {
223223
c.runtimeMetrics = internal.BoolEnv("DD_RUNTIME_METRICS_ENABLED", false)
224224
c.debug = internal.BoolEnv("DD_TRACE_DEBUG", false)
225225
c.enabled = internal.BoolEnv("DD_TRACE_ENABLED", true)
226-
// TODO(fg): set these to true before going GA with this.
227-
c.profilerEndpoints = internal.BoolEnv(traceprof.EndpointEnvVar, false)
228-
c.profilerHotspots = internal.BoolEnv(traceprof.CodeHotspotsEnvVar, false)
226+
c.profilerEndpoints = internal.BoolEnv(traceprof.EndpointEnvVar, true)
227+
c.profilerHotspots = internal.BoolEnv(traceprof.CodeHotspotsEnvVar, true)
229228

230229
for _, fn := range opts {
231230
fn(c)
@@ -690,7 +689,7 @@ func WithLogStartup(enabled bool) StartOption {
690689
// called "span id" and "local root span id" when new spans are created. You
691690
// should not use these label names in your own code when this is enabled. The
692691
// enabled value defaults to the value of the
693-
// DD_PROFILING_CODE_HOTSPOTS_COLLECTION_ENABLED env variable or false.
692+
// DD_PROFILING_CODE_HOTSPOTS_COLLECTION_ENABLED env variable or true.
694693
func WithProfilerCodeHotspots(enabled bool) StartOption {
695694
return func(c *config) {
696695
c.profilerHotspots = enabled
@@ -703,7 +702,7 @@ func WithProfilerCodeHotspots(enabled bool) StartOption {
703702
// its type is "http", "rpc" or "" (default). You should not use this label
704703
// name in your own code when this is enabled. The enabled value defaults to
705704
// the value of the DD_PROFILING_ENDPOINT_COLLECTION_ENABLED env variable or
706-
// false.
705+
// true.
707706
func WithProfilerEndpoints(enabled bool) StartOption {
708707
return func(c *config) {
709708
c.profilerEndpoints = enabled

ddtrace/tracer/option_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,28 +375,28 @@ func TestTracerOptionsDefaults(t *testing.T) {
375375
t.Run("profiler-endpoints", func(t *testing.T) {
376376
t.Run("default", func(t *testing.T) {
377377
c := newConfig()
378-
assert.False(t, c.profilerEndpoints)
378+
assert.True(t, c.profilerEndpoints)
379379
})
380380

381381
t.Run("override", func(t *testing.T) {
382-
os.Setenv(traceprof.EndpointEnvVar, "true")
382+
os.Setenv(traceprof.EndpointEnvVar, "false")
383383
defer os.Unsetenv(traceprof.EndpointEnvVar)
384384
c := newConfig()
385-
assert.True(t, c.profilerEndpoints)
385+
assert.False(t, c.profilerEndpoints)
386386
})
387387
})
388388

389389
t.Run("profiler-hotspots", func(t *testing.T) {
390390
t.Run("default", func(t *testing.T) {
391391
c := newConfig()
392-
assert.False(t, c.profilerHotspots)
392+
assert.True(t, c.profilerHotspots)
393393
})
394394

395395
t.Run("override", func(t *testing.T) {
396-
os.Setenv(traceprof.CodeHotspotsEnvVar, "true")
396+
os.Setenv(traceprof.CodeHotspotsEnvVar, "false")
397397
defer os.Unsetenv(traceprof.CodeHotspotsEnvVar)
398398
c := newConfig()
399-
assert.True(t, c.profilerHotspots)
399+
assert.False(t, c.profilerHotspots)
400400
})
401401
})
402402

profiler/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const (
4545
DefaultPeriod = time.Minute
4646

4747
// DefaultDuration specifies the default length of the CPU profile snapshot.
48-
DefaultDuration = time.Second * 15
48+
DefaultDuration = time.Minute
4949

5050
// DefaultUploadTimeout specifies the default timeout for uploading profiles.
5151
// It can be overwritten using the DD_PROFILING_UPLOAD_TIMEOUT env variable

0 commit comments

Comments
 (0)