Skip to content

Commit

Permalink
Add integration trace flag (#11520)
Browse files Browse the repository at this point in the history
* Add integration trace flag

* Address review

* Add hidden config
  • Loading branch information
coignetp authored Apr 1, 2022
1 parent 3b29134 commit af25c37
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 25 deletions.
69 changes: 44 additions & 25 deletions cmd/agent/common/commands/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,32 @@ import (
)

var (
checkRate bool
checkTimes int
checkPause int
checkName string
checkDelay int
logLevel string
formatJSON bool
formatTable bool
breakPoint string
fullSketches bool
saveFlare bool
profileMemory bool
profileMemoryDir string
profileMemoryFrames string
profileMemoryGC string
profileMemoryCombine string
profileMemorySort string
profileMemoryLimit string
profileMemoryDiff string
profileMemoryFilters string
profileMemoryUnit string
profileMemoryVerbose string
discoveryTimeout uint
discoveryRetryInterval uint
discoveryMinInstances uint
checkRate bool
checkTimes int
checkPause int
checkName string
checkDelay int
logLevel string
formatJSON bool
formatTable bool
breakPoint string
fullSketches bool
saveFlare bool
profileMemory bool
profileMemoryDir string
profileMemoryFrames string
profileMemoryGC string
profileMemoryCombine string
profileMemorySort string
profileMemoryLimit string
profileMemoryDiff string
profileMemoryFilters string
profileMemoryUnit string
profileMemoryVerbose string
discoveryTimeout uint
discoveryRetryInterval uint
discoveryMinInstances uint
generateIntegrationTraces bool
)

func setupCmd(cmd *cobra.Command) {
Expand Down Expand Up @@ -96,6 +97,7 @@ func setupCmd(cmd *cobra.Command) {
createHiddenStringFlag(cmd, &profileMemoryFilters, "m-filters", "", "comma-separated list of file path glob patterns to filter by")
createHiddenStringFlag(cmd, &profileMemoryUnit, "m-unit", "", "the binary unit to represent memory usage (kib, mb, etc.). the default is dynamic")
createHiddenStringFlag(cmd, &profileMemoryVerbose, "m-verbose", "", "whether or not to include potentially noisy sources")
createHiddenBooleanFlag(cmd, &generateIntegrationTraces, "m-trace", false, "send the integration traces")

cmd.SetArgs([]string{"checkName"})
}
Expand All @@ -122,6 +124,14 @@ func Check(loggerName config.LoggerName, confFilePath *string, flagNoColor *bool
color.NoColor = true
}

previousIntegrationTracing := false
if generateIntegrationTraces {
if config.Datadog.IsSet("integration_tracing") {
previousIntegrationTracing = config.Datadog.GetBool("integration_tracing")
}
config.Datadog.Set("integration_tracing", true)
}

if len(args) != 0 {
checkName = args[0]
} else {
Expand Down Expand Up @@ -432,6 +442,10 @@ func Check(loggerName config.LoggerName, confFilePath *string, flagNoColor *bool
writeCheckToFile(checkName, &checkFileOutput)
}

if generateIntegrationTraces {
config.Datadog.Set("integration_tracing", previousIntegrationTracing)
}

return nil
},
}
Expand Down Expand Up @@ -655,6 +669,11 @@ func createHiddenStringFlag(cmd *cobra.Command, p *string, name string, value st
cmd.Flags().MarkHidden(name) //nolint:errcheck
}

func createHiddenBooleanFlag(cmd *cobra.Command, p *bool, name string, value bool, usage string) {
cmd.Flags().BoolVar(p, name, value, usage)
cmd.Flags().MarkHidden(name) //nolint:errcheck
}

func populateMemoryProfileConfig(initConfig map[string]interface{}) error {
if profileMemoryFrames != "" {
profileMemoryFrames, err := strconv.Atoi(profileMemoryFrames)
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ func InitConfig(config Config) {
config.BindEnvAndSetDefault("cmd_port", 5001)
config.BindEnvAndSetDefault("cluster_agent.cmd_port", 5005)
config.BindEnvAndSetDefault("default_integration_http_timeout", 9)
config.BindEnvAndSetDefault("integration_tracing", false)
config.BindEnvAndSetDefault("enable_metadata_collection", true)
config.BindEnvAndSetDefault("enable_gohai", true)
config.BindEnvAndSetDefault("check_runners", int64(4))
Expand Down

0 comments on commit af25c37

Please sign in to comment.