99
1010 "github.com/buger/goterm"
1111 "github.com/compose-spec/compose-go/v2/types"
12+ "github.com/docker/compose/v2/internal/tracing"
1213 "github.com/docker/compose/v2/pkg/api"
1314 "github.com/docker/compose/v2/pkg/watch"
1415 "github.com/eiannone/keyboard"
@@ -48,6 +49,7 @@ type LogKeyboard struct {
4849 // services []string
4950 // printerStop func()
5051 // printerStart func()
52+ metrics tracing.KeyboardMetrics
5153}
5254
5355var KeyboardManager * LogKeyboard
@@ -66,6 +68,10 @@ func NewKeyboardManager(isDockerDesktopActive, isWatchConfigured bool, sc chan<-
6668 km .Watch .Watching = false
6769 km .Watch .WatchFn = watchFn
6870 km .SignalChannel = sc
71+ km .metrics = tracing.KeyboardMetrics {
72+ EnabledViewDockerDesktop : isDockerDesktopActive ,
73+ HasWatchConfig : isWatchConfigured ,
74+ }
6975 KeyboardManager = & km
7076}
7177
@@ -180,6 +186,7 @@ func (lk *LogKeyboard) openDockerDesktop(project *types.Project) {
180186 if ! lk .IsDockerDesktopActive {
181187 return
182188 }
189+ lk .metrics .ActivateViewDockerDesktop = true
183190 link := fmt .Sprintf ("docker-desktop://dashboard/apps/%s" , project .Name )
184191 err := open .Run (link )
185192 if err != nil {
@@ -198,6 +205,7 @@ func (lk *LogKeyboard) StartWatch(ctx context.Context, project *types.Project, o
198205 if ! lk .isWatching () && lk .Watch .Cancel != nil {
199206 lk .Watch .Cancel ()
200207 } else {
208+ lk .metrics .ActivateWatch = true
201209 lk .newContext (ctx )
202210 eg .Go (func () error {
203211 buildOpts := * options .Create .Build
@@ -304,6 +312,13 @@ func (lk *LogKeyboard) HandleKeyEvents(event keyboard.KeyEvent, ctx context.Cont
304312 lk .Watch .Cancel ()
305313 _ = eg .Wait ().ErrorOrNil () // Need to print this ?
306314 }
315+ go func () {
316+ tracing .SpanWrapFunc ("nav_menu" , tracing .KeyboardOptions (lk .metrics ),
317+ func (ctx context.Context ) error {
318+ return nil
319+ })(ctx )
320+ }()
321+
307322 // will notify main thread to kill and will handle gracefully
308323 lk .SignalChannel <- syscall .SIGINT
309324 case keyboard .KeyEnter :
0 commit comments