9
9
10
10
"github.com/buger/goterm"
11
11
"github.com/compose-spec/compose-go/v2/types"
12
+ "github.com/docker/compose/v2/internal/tracing"
12
13
"github.com/docker/compose/v2/pkg/api"
13
14
"github.com/docker/compose/v2/pkg/watch"
14
15
"github.com/eiannone/keyboard"
@@ -48,6 +49,7 @@ type LogKeyboard struct {
48
49
// services []string
49
50
// printerStop func()
50
51
// printerStart func()
52
+ metrics tracing.KeyboardMetrics
51
53
}
52
54
53
55
var KeyboardManager * LogKeyboard
@@ -66,6 +68,10 @@ func NewKeyboardManager(isDockerDesktopActive, isWatchConfigured bool, sc chan<-
66
68
km .Watch .Watching = false
67
69
km .Watch .WatchFn = watchFn
68
70
km .SignalChannel = sc
71
+ km .metrics = tracing.KeyboardMetrics {
72
+ EnabledViewDockerDesktop : isDockerDesktopActive ,
73
+ HasWatchConfig : isWatchConfigured ,
74
+ }
69
75
KeyboardManager = & km
70
76
}
71
77
@@ -180,6 +186,7 @@ func (lk *LogKeyboard) openDockerDesktop(project *types.Project) {
180
186
if ! lk .IsDockerDesktopActive {
181
187
return
182
188
}
189
+ lk .metrics .ActivateViewDockerDesktop = true
183
190
link := fmt .Sprintf ("docker-desktop://dashboard/apps/%s" , project .Name )
184
191
err := open .Run (link )
185
192
if err != nil {
@@ -291,6 +298,7 @@ func (lk *LogKeyboard) HandleKeyEvents(event keyboard.KeyEvent, ctx context.Cont
291
298
case 'V' :
292
299
lk .openDockerDesktop (project )
293
300
case 'W' :
301
+ lk .metrics .ActivateWatch = true
294
302
lk .StartWatch (ctx , project , options )
295
303
// case 'D':
296
304
// lk.debug(project)
@@ -304,6 +312,13 @@ func (lk *LogKeyboard) HandleKeyEvents(event keyboard.KeyEvent, ctx context.Cont
304
312
lk .Watch .Cancel ()
305
313
_ = eg .Wait ().ErrorOrNil () // Need to print this ?
306
314
}
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
+
307
322
// will notify main thread to kill and will handle gracefully
308
323
lk .SignalChannel <- syscall .SIGINT
309
324
case keyboard .KeyEnter :
0 commit comments