Skip to content

log: embed error hints in unstructured entries#82891

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
knz:20220614-hints
Nov 1, 2022
Merged

log: embed error hints in unstructured entries#82891
craig[bot] merged 1 commit intocockroachdb:masterfrom
knz:20220614-hints

Conversation

@knz
Copy link
Copy Markdown
Contributor

@knz knz commented Jun 14, 2022

Fixes #80875.
cc @dhartunian

With this commit, if a log.Infof (or warning, error, fatal etc) call
is passed an error object as argument, and that error object
contains hints, the hints are copied into the resulting log entry and
emitted to the sink.

At this time, we only have hints in very few places. This change is
thus merely infrastructure that will promote the implementation of
hints over time.

Example, before:

W220614 15:55:33.935575 1 cli/start.go:184  [n?] 5  cannot create trace dir; traces will not be dumped: mkdir inflight_trace_dump: permission denied

Example, after:

W220614 15:57:58.669410 1 cli/start.go:185  [n?] 5  cannot create trace dir; traces will not be dumped: mkdir inflight_trace_dump: permission denied
W220614 15:57:58.669410 1 cli/start.go:185  [n?] 5 +HINT: Try changing the CWD of the cockroach process to a writable directory.

Release note (cli change): In some cases, CockroachDB will now include
recommended remediation actions alongside log messages. We expect more
suggestions to be added in later versions.

@knz knz requested a review from a team June 14, 2022 16:01
@knz knz requested review from a team as code owners June 14, 2022 16:01
With this commit, if a `log.Infof` (or warning, error, fatal etc) call
is passed an `error` object as argument, and that error object
contains hints, the hints are copied into the resulting log entry and
emitted to the sink.

At this time, we only have hints in very few places. This change is
thus merely infrastructure that will promote the implementation of
hints over time.

Example, before:
```
W220614 15:55:33.935575 1 cli/start.go:184  [n?] 5  cannot create trace dir; traces will not be dumped: mkdir inflight_trace_dump: permission denied
```

Example, after:
```
W220614 15:57:58.669410 1 cli/start.go:185  [n?] 5  cannot create trace dir; traces will not be dumped: mkdir inflight_trace_dump: permission denied
W220614 15:57:58.669410 1 cli/start.go:185  [n?] 5 +HINT: Try changing the CWD of the cockroach process to a writable directory.
```

Release note (cli change): In some cases, CockroachDB will now include
recommended remediation actions alongside log messages. We expect more
suggestions to be added in later versions.
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@abarganier abarganier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm_strong:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @abarganier and @knz)


pkg/util/log/log_entry.go line 265 at r1 (raw file):

				h := errors.FlattenHints(e)
				if h != "" {
					buf.WriteString("\nHINT:")

nit: should this string contain a space after the colon to keep consistent with the redactable branch?

Suggestion:

"\nHINT:"

Copy link
Copy Markdown
Contributor

@cameronnunez cameronnunez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @abarganier and @knz)

@knz
Copy link
Copy Markdown
Contributor Author

knz commented Nov 1, 2022

bors r=abargainier,cameronnunez

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Nov 1, 2022

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

log: errors should include hints to the operator with remediation steps

4 participants