| 104 | } |
| 105 | |
| 106 | func (c *observabilityFlags) initialize(ctx *kingpin.ParseContext) error { |
| 107 | // write to a separate file per command and process execution to avoid |
| 108 | // conflicts with previously created files |
| 109 | command := "unknown" |
| 110 | if cmd := ctx.SelectedCommand; cmd != nil { |
| 111 | command = strings.ReplaceAll(cmd.FullCommand(), " ", "-") |
| 112 | } |
| 113 | |
| 114 | c.outputSubdirectoryName = clock.Now().Format("20060102-150405-") + command |
| 115 | |
| 116 | if (c.saveMetrics || c.pf.saveProfiles || c.pf.profileCPU) && c.outputDirectory == "" { |
| 117 | return errors.New("writing diagnostics output requires a non-empty directory name (specified with the '--diagnostics-output-directory' flag)") |
| 118 | } |
| 119 | |
| 120 | return nil |
| 121 | } |
| 122 | |
| 123 | // spanName specifies the name of the span at the start of a trace. A tracer is |
| 124 | // started only when spanName is not empty. |