Skip to content

Commit

Permalink
Merge pull request #428 from overmindtech/cancel-tracing
Browse files Browse the repository at this point in the history
Record if the CLI was aborted and how far it got
  • Loading branch information
DavidS-ovm authored Jun 21, 2024
2 parents 8745ea9 + 48c71c2 commit 9be307d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ func Execute() {
select {
case <-sigs:
log.Info("Received signal, shutting down")
if cmdSpan != nil {
cmdSpan.SetAttributes(attribute.Bool("ovm.cli.aborted", true))
}
cancel()
case <-ctx.Done():
}
Expand Down
11 changes: 10 additions & 1 deletion cmd/tea_terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ func (m *cmdModel) Init() tea.Cmd {
}

func (m *cmdModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
log.Debugf("cmdModel: Update %T received %#v", msg, msg)
lastMsgType := fmt.Sprintf("%T", msg)
if lastMsgType != "spinner.TickMsg" {
log.Debugf("cmdModel: Update %v received %#v", lastMsgType, msg)
if cmdSpan != nil && !slices.Contains([]string{"tea.KeyMsg", "tea.Quit"}, lastMsgType) {
cmdSpan.SetAttributes(attribute.String("ovm.cli.lastMsgType", lastMsgType))
}
}

cmds := []tea.Cmd{}

Expand All @@ -113,6 +119,9 @@ func (m *cmdModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

case tea.KeyMsg:
if msg.String() == "ctrl+c" {
if cmdSpan != nil {
cmdSpan.SetAttributes(attribute.Bool("ovm.cli.aborted", true))
}
return m, tea.Quit
}
case freezeViewMsg:
Expand Down

0 comments on commit 9be307d

Please sign in to comment.