Skip to content

Commit

Permalink
Capture error message for tracing on the span itself
Browse files Browse the repository at this point in the history
`span.RecordError` adds an `exception` span event, which is nive to have
to see the timing, but awful for aggregation in honeycomb. This also
adds the most relevant data to the span for easier querying.
  • Loading branch information
DavidS-ovm committed Jun 24, 2024
1 parent 906d924 commit fa5331f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ func Execute() {
// if printing the error was not requested by the appropriate
// wrapper, only record the data to honeycomb and sentry, the
// command already has handled logging
cmdSpan.SetAttributes(attribute.Bool("ovm.cli.fatalError", true))
cmdSpan.SetAttributes(
attribute.Bool("ovm.cli.fatalError", true),
attribute.String("ovm.cli.fatalError.msg", err.Error()),
)
cmdSpan.RecordError(err)
sentry.CaptureException(err)
}
Expand Down
1 change: 1 addition & 0 deletions cmd/tea_terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func (m *cmdModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
span.SetAttributes(
attribute.Bool("ovm.cli.fatalError", true),
attribute.Int("ovm.cli.fatalError.id", msg.id),
attribute.String("ovm.cli.fatalError.msg", msg.err.Error()),
)
sentry.CaptureException(msg.err)

Expand Down

0 comments on commit fa5331f

Please sign in to comment.