Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration trace flag #11520

Merged
merged 3 commits into from
Apr 1, 2022
Merged
Changes from 1 commit
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
Next Next commit
Add integration trace flag
  • Loading branch information
coignetp committed Mar 31, 2022
commit 7a9c88207e1123e0331df14c401c9fe5d8789d53
65 changes: 40 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,10 @@ func Check(loggerName config.LoggerName, confFilePath *string, flagNoColor *bool
color.NoColor = true
}

if generateIntegrationTraces {
os.Setenv("DDEV_TRACE_ENABLED", "true")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than env vars, is it possible to modify check config directly like we do for memory profiling?

}

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

if generateIntegrationTraces {
os.Setenv("DDEV_TRACE_ENABLED", "false")
}

return nil
},
}
Expand Down Expand Up @@ -655,6 +665,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