Skip to content

util/log: delay the formatting of log entries#58031

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
knz:20201216-log-json
Dec 28, 2020
Merged

util/log: delay the formatting of log entries#58031
craig[bot] merged 1 commit intocockroachdb:masterfrom
knz:20201216-log-json

Conversation

@knz
Copy link
Copy Markdown
Contributor

@knz knz commented Dec 17, 2020

Needed for #58126

Prior to this patch, the logging events were converted to a
logpb.Entry very early in the logging pipeline. This was forcing the
conversion of the logging tags to a flat string too early, and making
it hard for (e.g.) a JSON formatter to preserve the structure of
logging tags.

This patch averts this by introducing a new logEntry type which has
more-or-less the same structure as logpb.Entry but keep the logging
tags structured until the point the entry is formatted.

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@knz knz force-pushed the 20201216-log-json branch from dc69a2b to 39a4b4f Compare December 18, 2020 16:48
@knz knz changed the title [WIP] util/log: delay the formatting of log entries util/log: delay the formatting of log entries Dec 18, 2020
@knz knz requested a review from itsbilal December 18, 2020 16:49
@knz knz marked this pull request as ready for review December 18, 2020 16:49
@knz knz requested a review from a team as a code owner December 18, 2020 16:49
@knz knz force-pushed the 20201216-log-json branch 2 times, most recently from b3471b6 to 14d01f0 Compare December 18, 2020 18:40
@knz knz force-pushed the 20201216-log-json branch 3 times, most recently from d289642 to 41a572e Compare December 18, 2020 20:06
@knz
Copy link
Copy Markdown
Contributor Author

knz commented Dec 18, 2020

I am aware of a CI failure which is going to be fixed by a dep bump: cockroachdb/redact#14

@knz knz force-pushed the 20201216-log-json branch 3 times, most recently from e1ce16b to aff65d3 Compare December 21, 2020 15:10
Prior to this patch, the logging events were converted to a
`logpb.Entry` very early in the logging pipeline. This was forcing the
conversion of the logging tags to a flat string too early, and making
it hard for (e.g.) a JSON formatter to preserve the structure of
logging tags.

This patch averts this by introducing a new `logEntry` type which has
more-or-less the same structure as `logpb.Entry` but keep the logging
tags structured until the point the entry is formatted.

Release note: None
@knz knz force-pushed the 20201216-log-json branch from aff65d3 to a74b36a Compare December 22, 2020 16:08
Copy link
Copy Markdown
Contributor

@itsbilal itsbilal left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 21 of 21 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

@knz
Copy link
Copy Markdown
Contributor Author

knz commented Dec 28, 2020

thanks!

bors r=itsbilal

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Dec 28, 2020

Build succeeded:

@craig craig bot merged commit e2a49b5 into cockroachdb:master Dec 28, 2020
@knz knz deleted the 20201216-log-json branch December 28, 2020 18:54
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.

3 participants