Skip to content

Commit b62c4a8

Browse files
authored
fix(ddtrace/tracer): Disable agent features and remote configuration in CI Visibility agentless mode (#3026)
1 parent 14e38da commit b62c4a8

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

ddtrace/tracer/option.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,19 @@ func newConfig(opts ...StartOption) *config {
532532
if c.debug {
533533
log.SetLevel(log.LevelDebug)
534534
}
535-
// if using stdout or traces are disabled, agent is disabled
536-
agentDisabled := c.logToStdout || !c.enabled.current
535+
536+
// Check if CI Visibility mode is enabled
537+
if internal.BoolEnv(constants.CIVisibilityEnabledEnvironmentVariable, false) {
538+
c.ciVisibilityEnabled = true // Enable CI Visibility mode
539+
c.httpClientTimeout = time.Second * 45 // Increase timeout up to 45 seconds (same as other tracers in CIVis mode)
540+
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
541+
ciTransport := newCiVisibilityTransport(c) // Create a default CI Visibility Transport
542+
c.transport = ciTransport // Replace the default transport with the CI Visibility transport
543+
c.ciVisibilityAgentless = ciTransport.agentless
544+
}
545+
546+
// if using stdout or traces are disabled or we are in ci visibility agentless mode, agent is disabled
547+
agentDisabled := c.logToStdout || !c.enabled.current || c.ciVisibilityAgentless
537548
c.agent = loadAgentFeatures(agentDisabled, c.agentURL, c.httpClient)
538549
info, ok := debug.ReadBuildInfo()
539550
if !ok {
@@ -551,17 +562,6 @@ func newConfig(opts ...StartOption) *config {
551562
// This allows persisting the initial value of globalTags for future resets and updates.
552563
globalTagsOrigin := c.globalTags.cfgOrigin
553564
c.initGlobalTags(c.globalTags.get(), globalTagsOrigin)
554-
555-
// Check if CI Visibility mode is enabled
556-
if internal.BoolEnv(constants.CIVisibilityEnabledEnvironmentVariable, false) {
557-
c.ciVisibilityEnabled = true // Enable CI Visibility mode
558-
c.httpClientTimeout = time.Second * 45 // Increase timeout up to 45 seconds (same as other tracers in CIVis mode)
559-
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
560-
ciTransport := newCiVisibilityTransport(c) // Create a default CI Visibility Transport
561-
c.transport = ciTransport // Replace the default transport with the CI Visibility transport
562-
c.ciVisibilityAgentless = ciTransport.agentless
563-
}
564-
565565
return c
566566
}
567567

ddtrace/tracer/tracer.go

+13
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,19 @@ func Start(opts ...StartOption) {
165165
if t.dataStreams != nil {
166166
t.dataStreams.Start()
167167
}
168+
if t.config.ciVisibilityAgentless {
169+
// CI Visibility agentless mode doesn't require remote configuration.
170+
171+
// start instrumentation telemetry unless it is disabled through the
172+
// DD_INSTRUMENTATION_TELEMETRY_ENABLED env var
173+
startTelemetry(t.config)
174+
175+
// start appsec
176+
appsec.Start(t.config.appsecStartOptions...)
177+
_ = t.hostname() // Prime the hostname cache
178+
return
179+
}
180+
168181
// Start AppSec with remote configuration
169182
cfg := remoteconfig.DefaultClientConfig()
170183
cfg.AgentURL = t.config.agentURL.String()

0 commit comments

Comments
 (0)