Skip to content
2 changes: 1 addition & 1 deletion ddtrace/tracer/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func logStartup(t *tracer) {
RuntimeMetricsV2Enabled: t.config.internalConfig.RuntimeMetricsV2Enabled(),
ApplicationVersion: t.config.version,
ProfilerCodeHotspotsEnabled: t.config.internalConfig.ProfilerHotspotsEnabled(),
ProfilerEndpointsEnabled: t.config.profilerEndpoints,
ProfilerEndpointsEnabled: t.config.internalConfig.ProfilerEndpoints(),
Architecture: runtime.GOARCH,
GlobalService: globalconfig.ServiceName(),
LambdaMode: fmt.Sprintf("%t", t.config.logToStdout),
Expand Down
7 changes: 1 addition & 6 deletions ddtrace/tracer/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import (
"github.com/DataDog/dd-trace-go/v2/internal/orchestrion"
"github.com/DataDog/dd-trace-go/v2/internal/stableconfig"
"github.com/DataDog/dd-trace-go/v2/internal/telemetry"
"github.com/DataDog/dd-trace-go/v2/internal/traceprof"
"github.com/DataDog/dd-trace-go/v2/internal/version"

"github.com/DataDog/datadog-go/v5/statsd"
Expand Down Expand Up @@ -243,9 +242,6 @@ type config struct {
// errors will record a stack trace when this option is set.
noDebugStack bool

// profilerEndpoints specifies whether profiler endpoint filtering is enabled.
profilerEndpoints bool

// enabled reports whether tracing is enabled.
enabled dynamicConfig[bool]

Expand Down Expand Up @@ -468,7 +464,6 @@ func newConfig(opts ...StartOption) (*config, error) {
if _, ok := env.Lookup("DD_TRACE_ENABLED"); ok {
c.enabled.cfgOrigin = telemetry.OriginEnvVar
}
c.profilerEndpoints = internal.BoolEnv(traceprof.EndpointEnvVar, true)
if compatMode := env.Get("DD_TRACE_CLIENT_HOSTNAME_COMPAT"); compatMode != "" {
if semver.IsValid(compatMode) {
c.enableHostnameDetection = semver.Compare(semver.MajorMinor(compatMode), "v1.66") <= 0
Expand Down Expand Up @@ -1308,7 +1303,7 @@ func WithProfilerCodeHotspots(enabled bool) StartOption {
// true.
func WithProfilerEndpoints(enabled bool) StartOption {
return func(c *config) {
c.profilerEndpoints = enabled
c.internalConfig.SetProfilerEndpoints(enabled, telemetry.OriginCode)
}
}

Expand Down
4 changes: 2 additions & 2 deletions ddtrace/tracer/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,14 +763,14 @@ func TestTracerOptionsDefaults(t *testing.T) {
t.Run("default", func(t *testing.T) {
c, err := newTestConfig(WithAgentTimeout(2))
assert.NoError(t, err)
assert.True(t, c.profilerEndpoints)
assert.True(t, c.internalConfig.ProfilerEndpoints())
})

t.Run("override", func(t *testing.T) {
t.Setenv(traceprof.EndpointEnvVar, "false")
c, err := newTestConfig(WithAgentTimeout(2))
assert.NoError(t, err)
assert.False(t, c.profilerEndpoints)
assert.False(t, c.internalConfig.ProfilerEndpoints())
})
})

Expand Down
2 changes: 1 addition & 1 deletion ddtrace/tracer/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func startTelemetry(c *config) telemetry.Client {
{Name: "runtime_metrics_v2_enabled", Value: c.internalConfig.RuntimeMetricsV2Enabled()},
{Name: "dogstatsd_addr", Value: c.dogstatsdAddr},
{Name: "debug_stack_enabled", Value: !c.noDebugStack},
{Name: "profiling_endpoints_enabled", Value: c.internalConfig.ProfilerEndpoints()},
{Name: "profiling_hotspots_enabled", Value: c.internalConfig.ProfilerHotspotsEnabled()},
{Name: "profiling_endpoints_enabled", Value: c.profilerEndpoints},
{Name: "trace_span_attribute_schema", Value: c.spanAttributeSchemaVersion},
{Name: "trace_peer_service_defaults_enabled", Value: c.peerServiceDefaultsEnabled},
{Name: "orchestrion_enabled", Value: c.orchestrionCfg.Enabled, Origin: telemetry.OriginCode},
Expand Down
4 changes: 2 additions & 2 deletions ddtrace/tracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ func (t *tracer) StartSpan(operationName string, options ...StartSpanOption) *Sp
log.Debug("Started Span: %v, Operation: %s, Resource: %s, Tags: %v, %v", //nolint:gocritic // Debug logging needs full span representation
span, span.name, span.resource, span.meta, span.metrics)
}
if t.config.internalConfig.ProfilerHotspotsEnabled() || t.config.profilerEndpoints {
if t.config.internalConfig.ProfilerHotspotsEnabled() || t.config.internalConfig.ProfilerEndpoints() {
t.applyPPROFLabels(span.pprofCtxRestore, span)
} else {
span.pprofCtxRestore = nil
Expand Down Expand Up @@ -843,7 +843,7 @@ func (t *tracer) applyPPROFLabels(ctx gocontext.Context, span *Span) {
if t.config.internalConfig.ProfilerHotspotsEnabled() {
labels = append(labels, traceprof.SpanID, strconv.FormatUint(span.spanID, 10))
}
if t.config.profilerEndpoints && localRootSpan != nil {
if t.config.internalConfig.ProfilerEndpoints() && localRootSpan != nil {
localRootSpan.mu.RLock()
if spanResourcePIISafe(localRootSpan) {
labels = append(labels, traceprof.TraceEndpoint, localRootSpan.resource)
Expand Down
15 changes: 14 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func loadConfig() *Config {
cfg.runtimeMetrics = provider.getBool("DD_RUNTIME_METRICS_ENABLED", false)
cfg.runtimeMetricsV2 = provider.getBool("DD_RUNTIME_METRICS_V2_ENABLED", true)
cfg.profilerHotspots = provider.getBool("DD_PROFILING_CODE_HOTSPOTS_COLLECTION_ENABLED", true)
cfg.profilerEndpoints = provider.getBool("DD_PROFILING_ENDPOINT_COLLECTION_ENABLED", false)
cfg.profilerEndpoints = provider.getBool("DD_PROFILING_ENDPOINT_COLLECTION_ENABLED", true)
cfg.spanAttributeSchemaVersion = provider.getInt("DD_TRACE_SPAN_ATTRIBUTE_SCHEMA", 0)
cfg.peerServiceDefaultsEnabled = provider.getBool("DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED", false)
cfg.peerServiceMappings = provider.getMap("DD_TRACE_PEER_SERVICE_MAPPING", nil)
Expand Down Expand Up @@ -137,6 +137,19 @@ func (c *Config) SetDebug(enabled bool, origin telemetry.Origin) {
telemetry.RegisterAppConfig("DD_TRACE_DEBUG", enabled, origin)
}

func (c *Config) ProfilerEndpoints() bool {
c.mu.RLock()
defer c.mu.RUnlock()
return c.profilerEndpoints
}

func (c *Config) SetProfilerEndpoints(enabled bool, origin telemetry.Origin) {
c.mu.Lock()
defer c.mu.Unlock()
c.profilerEndpoints = enabled
telemetry.RegisterAppConfig("DD_PROFILING_ENDPOINT_COLLECTION_ENABLED", enabled, origin)
}

func (c *Config) ProfilerHotspotsEnabled() bool {
c.mu.RLock()
defer c.mu.RUnlock()
Expand Down
Loading