From fd5a429898eb5bb62059e262b0ee4f10970f320f Mon Sep 17 00:00:00 2001 From: Nick Ripley Date: Tue, 15 Feb 2022 08:23:18 -0500 Subject: [PATCH] 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. --- ddtrace/tracer/log_test.go | 8 ++++---- ddtrace/tracer/option.go | 9 ++++----- ddtrace/tracer/option_test.go | 12 ++++++------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/ddtrace/tracer/log_test.go b/ddtrace/tracer/log_test.go index 8233717ce3..8ee9bc7c1a 100644 --- a/ddtrace/tracer/log_test.go +++ b/ddtrace/tracer/log_test.go @@ -26,7 +26,7 @@ func TestStartupLog(t *testing.T) { logStartup(tracer) lines := removeAppSec(tp.Lines()) assert.Len(lines, 2) - 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]) + 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]) }) t.Run("configured", func(t *testing.T) { @@ -55,7 +55,7 @@ func TestStartupLog(t *testing.T) { tp.Reset() logStartup(tracer) assert.Len(tp.Lines(), 2) - 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]) + 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]) }) t.Run("errors", func(t *testing.T) { @@ -69,7 +69,7 @@ func TestStartupLog(t *testing.T) { tp.Reset() logStartup(tracer) assert.Len(tp.Lines(), 2) - 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]) + 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]) }) t.Run("lambda", func(t *testing.T) { @@ -81,7 +81,7 @@ func TestStartupLog(t *testing.T) { tp.Reset() logStartup(tracer) assert.Len(tp.Lines(), 1) - 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]) + 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]) }) } diff --git a/ddtrace/tracer/option.go b/ddtrace/tracer/option.go index 9d1f2e1caa..2dc38796ad 100644 --- a/ddtrace/tracer/option.go +++ b/ddtrace/tracer/option.go @@ -223,9 +223,8 @@ func newConfig(opts ...StartOption) *config { c.runtimeMetrics = internal.BoolEnv("DD_RUNTIME_METRICS_ENABLED", false) c.debug = internal.BoolEnv("DD_TRACE_DEBUG", false) c.enabled = internal.BoolEnv("DD_TRACE_ENABLED", true) - // TODO(fg): set these to true before going GA with this. - c.profilerEndpoints = internal.BoolEnv(traceprof.EndpointEnvVar, false) - c.profilerHotspots = internal.BoolEnv(traceprof.CodeHotspotsEnvVar, false) + c.profilerEndpoints = internal.BoolEnv(traceprof.EndpointEnvVar, true) + c.profilerHotspots = internal.BoolEnv(traceprof.CodeHotspotsEnvVar, true) for _, fn := range opts { fn(c) @@ -690,7 +689,7 @@ func WithLogStartup(enabled bool) StartOption { // called "span id" and "local root span id" when new spans are created. You // should not use these label names in your own code when this is enabled. The // enabled value defaults to the value of the -// DD_PROFILING_CODE_HOTSPOTS_COLLECTION_ENABLED env variable or false. +// DD_PROFILING_CODE_HOTSPOTS_COLLECTION_ENABLED env variable or true. func WithProfilerCodeHotspots(enabled bool) StartOption { return func(c *config) { c.profilerHotspots = enabled @@ -703,7 +702,7 @@ func WithProfilerCodeHotspots(enabled bool) StartOption { // its type is "http", "rpc" or "" (default). You should not use this label // name in your own code when this is enabled. The enabled value defaults to // the value of the DD_PROFILING_ENDPOINT_COLLECTION_ENABLED env variable or -// false. +// true. func WithProfilerEndpoints(enabled bool) StartOption { return func(c *config) { c.profilerEndpoints = enabled diff --git a/ddtrace/tracer/option_test.go b/ddtrace/tracer/option_test.go index 1d6100513a..a055c4fb7a 100644 --- a/ddtrace/tracer/option_test.go +++ b/ddtrace/tracer/option_test.go @@ -375,28 +375,28 @@ func TestTracerOptionsDefaults(t *testing.T) { t.Run("profiler-endpoints", func(t *testing.T) { t.Run("default", func(t *testing.T) { c := newConfig() - assert.False(t, c.profilerEndpoints) + assert.True(t, c.profilerEndpoints) }) t.Run("override", func(t *testing.T) { - os.Setenv(traceprof.EndpointEnvVar, "true") + os.Setenv(traceprof.EndpointEnvVar, "false") defer os.Unsetenv(traceprof.EndpointEnvVar) c := newConfig() - assert.True(t, c.profilerEndpoints) + assert.False(t, c.profilerEndpoints) }) }) t.Run("profiler-hotspots", func(t *testing.T) { t.Run("default", func(t *testing.T) { c := newConfig() - assert.False(t, c.profilerHotspots) + assert.True(t, c.profilerHotspots) }) t.Run("override", func(t *testing.T) { - os.Setenv(traceprof.CodeHotspotsEnvVar, "true") + os.Setenv(traceprof.CodeHotspotsEnvVar, "false") defer os.Unsetenv(traceprof.CodeHotspotsEnvVar) c := newConfig() - assert.True(t, c.profilerHotspots) + assert.False(t, c.profilerHotspots) }) })