ipn/localapi,client/local: add debug watcher for bus events (#16239)

Updates: #15160

Signed-off-by: Claus Lensbøl <claus@tailscale.com>
This commit is contained in:
Claus Lensbøl
2025-06-11 14:22:30 -04:00
committed by GitHub
parent 3b25e94352
commit 6010812f0c
5 changed files with 154 additions and 37 deletions

View File

@@ -102,6 +102,12 @@ func debugCmd() *ffcli.Command {
return fs
})(),
},
{
Name: "daemon-bus-events",
ShortUsage: "tailscale debug daemon-bus-events",
Exec: runDaemonBusEvents,
ShortHelp: "Watch events on the tailscaled bus",
},
{
Name: "metrics",
ShortUsage: "tailscale debug metrics",
@@ -784,6 +790,24 @@ func runDaemonLogs(ctx context.Context, args []string) error {
}
}
func runDaemonBusEvents(ctx context.Context, args []string) error {
logs, err := localClient.StreamBusEvents(ctx)
if err != nil {
return err
}
defer logs.Close()
d := json.NewDecoder(bufio.NewReader(logs))
for {
var line eventbus.DebugEvent
err := d.Decode(&line)
if err != nil {
return err
}
fmt.Printf("[%d][%q][from: %q][to: %q] %s\n", line.Count, line.Type,
line.From, line.To, line.Event)
}
}
var metricsArgs struct {
watch bool
}

View File

@@ -719,6 +719,7 @@ func tryEngine(logf logger.Logf, sys *tsd.System, name string) (onlyNetstack boo
Dialer: sys.Dialer.Get(),
SetSubsystem: sys.Set,
ControlKnobs: sys.ControlKnobs(),
EventBus: sys.Bus.Get(),
DriveForLocal: driveimpl.NewFileSystemForLocal(logf),
}