Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions ddtrace/tracer/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ type config struct {
// retryInterval is the interval between agent connection retries. It has no effect if sendRetries is not set
retryInterval time.Duration

// logStartup, when true, causes various startup info to be written
// when the tracer starts.
logStartup bool

// serviceName specifies the name of this application.
serviceName string

Expand Down Expand Up @@ -476,7 +472,6 @@ func newConfig(opts ...StartOption) (*config, error) {
c.isLambdaFunction = true
}
}
c.logStartup = internal.BoolEnv("DD_TRACE_STARTUP_LOGS", true)
c.runtimeMetrics = internal.BoolVal(getDDorOtelConfig("metrics"), false)
c.runtimeMetricsV2 = internal.BoolEnv("DD_RUNTIME_METRICS_V2_ENABLED", true)
c.logDirectory = env.Get("DD_TRACE_LOG_DIRECTORY")
Expand Down Expand Up @@ -613,11 +608,11 @@ func newConfig(opts ...StartOption) (*config, error) {
}
// Check if CI Visibility mode is enabled
if internal.BoolEnv(constants.CIVisibilityEnabledEnvironmentVariable, false) {
c.ciVisibilityEnabled = true // Enable CI Visibility mode
c.httpClientTimeout = time.Second * 45 // Increase timeout up to 45 seconds (same as other tracers in CIVis mode)
c.logStartup = false // If we are in CI Visibility mode we don't want to log the startup to stdout to avoid polluting the output
ciTransport := newCiVisibilityTransport(c) // Create a default CI Visibility Transport
c.transport = ciTransport // Replace the default transport with the CI Visibility transport
c.ciVisibilityEnabled = true // Enable CI Visibility mode
c.httpClientTimeout = time.Second * 45 // Increase timeout up to 45 seconds (same as other tracers in CIVis mode)
c.internalConfig.SetLogStartup(false, internalconfig.OriginCalculated) // If we are in CI Visibility mode we don't want to log the startup to stdout to avoid polluting the output
ciTransport := newCiVisibilityTransport(c) // Create a default CI Visibility Transport
c.transport = ciTransport // Replace the default transport with the CI Visibility transport
c.ciVisibilityAgentless = ciTransport.agentless
c.ciVisibilityNoopTracer = internal.BoolEnv(constants.CIVisibilityUseNoopTracer, false)
}
Expand Down Expand Up @@ -1300,7 +1295,7 @@ func WithTraceEnabled(enabled bool) StartOption {
// WithLogStartup allows enabling or disabling the startup log.
func WithLogStartup(enabled bool) StartOption {
return func(c *config) {
c.logStartup = enabled
c.internalConfig.SetLogStartup(enabled, internalconfig.OriginCode)
}
}

Expand Down
6 changes: 3 additions & 3 deletions ddtrace/tracer/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1547,11 +1547,11 @@ func TestWithTraceEnabled(t *testing.T) {
func TestWithLogStartup(t *testing.T) {
c, err := newTestConfig()
assert.NoError(t, err)
assert.True(t, c.logStartup)
assert.True(t, c.internalConfig.LogStartup())
WithLogStartup(false)(c)
assert.False(t, c.logStartup)
assert.False(t, c.internalConfig.LogStartup())
WithLogStartup(true)(c)
assert.True(t, c.logStartup)
assert.True(t, c.internalConfig.LogStartup())
}

func TestWithHeaderTags(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion ddtrace/tracer/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func reportTelemetryOnAppStarted(c telemetry.Configuration) {
// event is sent with tracer config data.
// Note that the tracer is not considered as a standalone product by telemetry so we cannot send
// an app-product-change event for the tracer.
// TODO (APMAPI-1771): This function should be deleted once config migration is complete
func startTelemetry(c *config) telemetry.Client {
if telemetry.Disabled() {
// Do not do extra work populating config data if instrumentation telemetry is disabled.
Expand All @@ -42,7 +43,7 @@ func startTelemetry(c *config) telemetry.Client {
{Name: "lambda_mode", Value: c.logToStdout},
{Name: "send_retries", Value: c.sendRetries},
{Name: "retry_interval", Value: c.retryInterval},
{Name: "trace_startup_logs_enabled", Value: c.logStartup},
{Name: "trace_startup_logs_enabled", Value: c.internalConfig.LogStartup()},
{Name: "service", Value: c.serviceName},
{Name: "universal_version", Value: c.universalVersion},
{Name: "env", Value: c.env},
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/tracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func Start(opts ...StartOption) error {
return fmt.Errorf("failed to start llmobs: %w", err)
}
}
if t.config.logStartup {
if t.config.internalConfig.LogStartup() {
logStartup(t)
}

Expand Down
20 changes: 17 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ const (
type Config struct {
mu sync.RWMutex
// Config fields are protected by the mutex.
agentURL *url.URL
debug bool
agentURL *url.URL
debug bool
// logStartup, when true, causes various startup info to be written when the tracer starts.
logStartup bool
serviceName string
version string
Expand Down Expand Up @@ -73,7 +74,7 @@ func loadConfig() *Config {
// TODO: Use defaults from config json instead of hardcoding them here
cfg.agentURL = provider.getURL("DD_TRACE_AGENT_URL", &url.URL{Scheme: "http", Host: "localhost:8126"})
cfg.debug = provider.getBool("DD_TRACE_DEBUG", false)
cfg.logStartup = provider.getBool("DD_TRACE_STARTUP_LOGS", false)
cfg.logStartup = provider.getBool("DD_TRACE_STARTUP_LOGS", true)
cfg.serviceName = provider.getString("DD_SERVICE", "")
cfg.version = provider.getString("DD_VERSION", "")
cfg.env = provider.getString("DD_ENV", "")
Expand Down Expand Up @@ -147,3 +148,16 @@ func (c *Config) SetDataStreamsMonitoringEnabled(enabled bool, origin telemetry.
c.dataStreamsMonitoringEnabled = enabled
telemetry.RegisterAppConfig("DD_DATA_STREAMS_ENABLED", enabled, origin)
}

func (c *Config) LogStartup() bool {
c.mu.RLock()
defer c.mu.RUnlock()
return c.logStartup
}

func (c *Config) SetLogStartup(enabled bool, origin telemetry.Origin) {
c.mu.Lock()
defer c.mu.Unlock()
c.logStartup = enabled
telemetry.RegisterAppConfig("DD_TRACE_STARTUP_LOGS", enabled, origin)
}
Loading