Skip to content

Commit e0fe551

Browse files
committed
migrate noDebugStack
1 parent 94067c6 commit e0fe551

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
@@ -232,10 +232,6 @@ type config struct {
232232
// It defaults to time.Ticker; replaced in tests.
233233
tickChan <-chan time.Time
234234

235-
// noDebugStack disables the collection of debug stack traces globally. No traces reporting
236-
// errors will record a stack trace when this option is set.
237-
noDebugStack bool
238-
239235
// profilerEndpoints specifies whether profiler endpoint filtering is enabled.
240236
profilerEndpoints bool
241237

@@ -885,7 +881,7 @@ func WithLogger(logger Logger) StartOption {
885881
// FinishOption.
886882
func WithDebugStack(enabled bool) StartOption {
887883
return func(c *config) {
888-
c.noDebugStack = !enabled
884+
c.internalConfig.SetDebugStack(enabled, internalconfig.OriginCode)
889885
}
890886
}
891887

ddtrace/tracer/telemetry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ 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},
55+
{Name: "debug_stack_enabled", Value: c.internalConfig.DebugStack()},
5656
{Name: "profiling_hotspots_enabled", Value: c.internalConfig.ProfilerHotspotsEnabled()},
5757
{Name: "profiling_endpoints_enabled", Value: c.profilerEndpoints},
5858
{Name: "trace_span_attribute_schema", Value: c.spanAttributeSchemaVersion},

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
@@ -335,3 +338,16 @@ func (c *Config) SetSpanTimeout(timeout time.Duration, origin telemetry.Origin)
335338
c.spanTimeout = timeout
336339
telemetry.RegisterAppConfig("DD_TRACE_ABANDONED_SPAN_TIMEOUT", timeout, origin)
337340
}
341+
342+
func (c *Config) DebugStack() bool {
343+
c.mu.RLock()
344+
defer c.mu.RUnlock()
345+
return c.debugStack
346+
}
347+
348+
func (c *Config) SetDebugStack(enabled bool, origin telemetry.Origin) {
349+
c.mu.Lock()
350+
defer c.mu.Unlock()
351+
c.debugStack = enabled
352+
telemetry.RegisterAppConfig("DD_TRACE_DEBUG_STACK", enabled, origin)
353+
}

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
@@ -411,6 +411,9 @@
411411
"DD_TRACE_DEBUG_ABANDONED_SPANS": [
412412
"A"
413413
],
414+
"DD_TRACE_DEBUG_STACK": [
415+
"A"
416+
],
414417
"DD_TRACE_DEBUG_SEELOG_WORKAROUND": [
415418
"A"
416419
],

0 commit comments

Comments
 (0)