diff --git a/ddtrace/tracer/option.go b/ddtrace/tracer/option.go index 5868086037..ae2594aa50 100644 --- a/ddtrace/tracer/option.go +++ b/ddtrace/tracer/option.go @@ -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 { @@ -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 } diff --git a/ddtrace/tracer/tracer.go b/ddtrace/tracer/tracer.go index a0de522d24..e6bfcc7b49 100644 --- a/ddtrace/tracer/tracer.go +++ b/ddtrace/tracer/tracer.go @@ -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()