Skip to content

Commit

Permalink
fix(ddtrace/tracer): Disable agent features and remote configuration …
Browse files Browse the repository at this point in the history
…in CI Visibility agentless mode (#3026)
  • Loading branch information
tonyredondo authored Dec 12, 2024
1 parent 14e38da commit b62c4a8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
26 changes: 13 additions & 13 deletions ddtrace/tracer/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,19 @@ func newConfig(opts ...StartOption) *config {
if c.debug {
log.SetLevel(log.LevelDebug)
}
// if using stdout or traces are disabled, agent is disabled
agentDisabled := c.logToStdout || !c.enabled.current

// 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.ciVisibilityAgentless = ciTransport.agentless
}

// if using stdout or traces are disabled or we are in ci visibility agentless mode, agent is disabled
agentDisabled := c.logToStdout || !c.enabled.current || c.ciVisibilityAgentless
c.agent = loadAgentFeatures(agentDisabled, c.agentURL, c.httpClient)
info, ok := debug.ReadBuildInfo()
if !ok {
Expand All @@ -551,17 +562,6 @@ func newConfig(opts ...StartOption) *config {
// This allows persisting the initial value of globalTags for future resets and updates.
globalTagsOrigin := c.globalTags.cfgOrigin
c.initGlobalTags(c.globalTags.get(), globalTagsOrigin)

// 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.ciVisibilityAgentless = ciTransport.agentless
}

return c
}

Expand Down
13 changes: 13 additions & 0 deletions ddtrace/tracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,19 @@ func Start(opts ...StartOption) {
if t.dataStreams != nil {
t.dataStreams.Start()
}
if t.config.ciVisibilityAgentless {
// CI Visibility agentless mode doesn't require remote configuration.

// start instrumentation telemetry unless it is disabled through the
// DD_INSTRUMENTATION_TELEMETRY_ENABLED env var
startTelemetry(t.config)

// start appsec
appsec.Start(t.config.appsecStartOptions...)
_ = t.hostname() // Prime the hostname cache
return
}

// Start AppSec with remote configuration
cfg := remoteconfig.DefaultClientConfig()
cfg.AgentURL = t.config.agentURL.String()
Expand Down

0 comments on commit b62c4a8

Please sign in to comment.