Skip to content

Commit cb207bb

Browse files
committed
migrate noDebugStack
1 parent f74672a commit cb207bb

File tree

6 files changed

+24
-8
lines changed

6 files changed

+24
-8
lines changed

ddtrace/tracer/option.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,6 @@ type config struct {
231231
// It defaults to time.Ticker; replaced in tests.
232232
tickChan <-chan time.Time
233233

234-
// noDebugStack disables the collection of debug stack traces globally. No traces reporting
235-
// errors will record a stack trace when this option is set.
236-
noDebugStack bool
237-
238234
// enabled reports whether tracing is enabled.
239235
enabled dynamicConfig[bool]
240236

@@ -880,7 +876,7 @@ func WithLogger(logger Logger) StartOption {
880876
// FinishOption.
881877
func WithDebugStack(enabled bool) StartOption {
882878
return func(c *config) {
883-
c.noDebugStack = !enabled
879+
c.internalConfig.SetDebugStack(enabled, internalconfig.OriginCode)
884880
}
885881
}
886882

ddtrace/tracer/telemetry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ func startTelemetry(c *config) telemetry.Client {
5252
{Name: "agent_hostname", Value: c.hostname},
5353
{Name: "runtime_metrics_v2_enabled", Value: c.internalConfig.RuntimeMetricsV2Enabled()},
5454
{Name: "dogstatsd_addr", Value: c.dogstatsdAddr},
55-
{Name: "debug_stack_enabled", Value: !c.noDebugStack},
5655
{Name: "profiling_endpoints_enabled", Value: c.internalConfig.ProfilerEndpoints()},
56+
{Name: "debug_stack_enabled", Value: c.internalConfig.DebugStack()},
5757
{Name: "profiling_hotspots_enabled", Value: c.internalConfig.ProfilerHotspotsEnabled()},
5858
{Name: "trace_span_attribute_schema", Value: c.spanAttributeSchemaVersion},
5959
{Name: "trace_peer_service_defaults_enabled", Value: c.peerServiceDefaultsEnabled},

ddtrace/tracer/tracer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ func (t *tracer) StartSpan(operationName string, options ...StartSpanOption) *Sp
764764
if span.service == "" {
765765
span.service = t.config.serviceName
766766
}
767-
span.noDebugStack = t.config.noDebugStack
767+
span.noDebugStack = !t.config.internalConfig.DebugStack()
768768
if t.config.hostname != "" {
769769
span.setMeta(keyHostname, t.config.hostname)
770770
}

internal/config/config.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ type Config struct {
7979
logToStdout bool
8080
// isLambdaFunction, if true, indicates we are in a lambda function
8181
isLambdaFunction bool
82+
// debugStack enables the collection of debug stack traces globally. Error traces will not record a stack trace when this option is false.
83+
debugStack bool
8284
}
8385

8486
// loadConfig initializes and returns a new config by reading from all configured sources.
@@ -115,6 +117,7 @@ func loadConfig() *Config {
115117
cfg.logDirectory = provider.getString("DD_TRACE_LOG_DIRECTORY", "")
116118
cfg.traceRateLimitPerSecond = provider.getFloatWithValidator("DD_TRACE_RATE_LIMIT", DefaultRateLimit, validateRateLimit)
117119
cfg.globalSampleRate = provider.getFloatWithValidator("DD_TRACE_SAMPLE_RATE", math.NaN(), validateSampleRate)
120+
cfg.debugStack = provider.getBool("DD_TRACE_DEBUG_STACK", true)
118121

119122
// AWS_LAMBDA_FUNCTION_NAME being set indicates that we're running in an AWS Lambda environment.
120123
// See: https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html
@@ -355,3 +358,16 @@ func (c *Config) SetSpanTimeout(timeout time.Duration, origin telemetry.Origin)
355358
c.spanTimeout = timeout
356359
telemetry.RegisterAppConfig("DD_TRACE_ABANDONED_SPAN_TIMEOUT", timeout, origin)
357360
}
361+
362+
func (c *Config) DebugStack() bool {
363+
c.mu.RLock()
364+
defer c.mu.RUnlock()
365+
return c.debugStack
366+
}
367+
368+
func (c *Config) SetDebugStack(enabled bool, origin telemetry.Origin) {
369+
c.mu.Lock()
370+
defer c.mu.Unlock()
371+
c.debugStack = enabled
372+
telemetry.RegisterAppConfig("DD_TRACE_DEBUG_STACK", enabled, origin)
373+
}

internal/env/supported_configurations.gen.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/env/supported_configurations.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,9 @@
414414
"DD_TRACE_DEBUG_ABANDONED_SPANS": [
415415
"A"
416416
],
417+
"DD_TRACE_DEBUG_STACK": [
418+
"A"
419+
],
417420
"DD_TRACE_DEBUG_SEELOG_WORKAROUND": [
418421
"A"
419422
],

0 commit comments

Comments
 (0)