@@ -8,17 +8,50 @@ import ( |
| 8 | 8 | |
| 9 | 9 | "github.com/spf13/cobra" |
| 10 | 10 | |
| 11 | + "github.com/tenseleyFlow/shithub/internal/infra/config" |
| 11 | 12 | "github.com/tenseleyFlow/shithub/internal/version" |
| 12 | 13 | ) |
| 13 | 14 | |
| 14 | 15 | var versionCmd = &cobra.Command{ |
| 15 | 16 | Use: "version", |
| 16 | | - Short: "Print version, commit, build time, and Go runtime", |
| 17 | + Short: "Print version, commit, build time, Go runtime, and configured observability sinks", |
| 17 | 18 | Run: func(cmd *cobra.Command, args []string) { |
| 18 | 19 | fmt.Printf("shithubd %s\n", version.Version) |
| 19 | 20 | fmt.Printf(" commit: %s\n", version.Commit) |
| 20 | 21 | fmt.Printf(" built: %s\n", version.BuiltAt) |
| 21 | 22 | fmt.Printf(" go: %s\n", runtime.Version()) |
| 22 | 23 | fmt.Printf(" os: %s/%s\n", runtime.GOOS, runtime.GOARCH) |
| 24 | + |
| 25 | + cfg, err := config.Load(nil) |
| 26 | + if err != nil { |
| 27 | + fmt.Printf(" config: <invalid: %s>\n", err) |
| 28 | + return |
| 29 | + } |
| 30 | + fmt.Printf(" env: %s\n", cfg.Env) |
| 31 | + fmt.Printf(" log: %s/%s\n", cfg.Log.Format, cfg.Log.Level) |
| 32 | + fmt.Printf(" metrics: %s\n", boolStr(cfg.Metrics.Enabled)) |
| 33 | + fmt.Printf(" tracing: %s\n", tracingStr(cfg.Tracing)) |
| 34 | + fmt.Printf(" errrep: %s\n", errrepStr(cfg.ErrorReporting)) |
| 23 | 35 | }, |
| 24 | 36 | } |
| 37 | + |
| 38 | +func boolStr(b bool) string { |
| 39 | + if b { |
| 40 | + return "enabled" |
| 41 | + } |
| 42 | + return "disabled" |
| 43 | +} |
| 44 | + |
| 45 | +func tracingStr(t config.TracingConfig) string { |
| 46 | + if !t.Enabled { |
| 47 | + return "disabled" |
| 48 | + } |
| 49 | + return fmt.Sprintf("enabled (endpoint=%s, sample=%.2f)", t.Endpoint, t.SampleRate) |
| 50 | +} |
| 51 | + |
| 52 | +func errrepStr(e config.ErrorReportingConfig) string { |
| 53 | + if e.DSN == "" { |
| 54 | + return "disabled" |
| 55 | + } |
| 56 | + return "enabled (dsn=*** env=" + e.Environment + ")" |
| 57 | +} |