[Java Client] Switch from pretty print to compact print for configs #11609
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
When running the
ProducerStatsRecorderImpl
andConsumerStatsRecorderImpl
, there are several log lines that print configuration in pretty print formatting. This output can be easier to read, but it adds verbosity to logs, especially if there are many of these configs printing for many topics. Practically speaking, when tailing logs, these pretty printed configs take up much of one's screen and make it harder to see other logging events. Also, pretty printing can be problematic when using log aggregators that do not have good multi-line support, as the logs won't be grouped properly.I propose switching to a compact output for these log lines to decrease the number of lines output and to make it easier for log aggregators to easily capture the whole log line.
Here is a sample of the current logging output:
Further, I think this change is in line with other Pulsar logging. We already print out configuration in a compact format when starting a broker:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
Lines 790 to 791 in d57c1d2
Modifications
writerWithDefaultPrettyPrinter
method call.Verifying this change
This is a trivial rework. The result of this update is that log lines will be compact json on a single line instead of pretty printed json on many lines.
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation
N/A