NIFI-15989: Improve purge threshold time formatting#11313
Conversation
Update the purge threshold output to be more human readable. Existing output will show the value in milliseconds which can be difficult to read quickly. Use Apache Commons lang3 to get the threhold in a format like "30 days", "7 days 4 hours", etc.
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for proposing this improvement @ohnoitsyou.
Although other modules include the commons-lang3 dependency, introducing this dependency for the sole purpose of improving the logging message does not seem worth the addition.
|
I had considered adding a function to the FormatUtils located in commons. Unfortunately it also doesn't have lang3 in it, but it would centralize the functionality. The end user this request came from only mentioned this particular log. I'm sure there are other places it would make sense to have a log message formatted in this way. |
|
In relation to log formatting, additional dependencies should be avoided. There is certainly a balance to strike between readability and consistency, but in this case, the log message already includes the number of units, which also makes it more consistent for potential parsing. With that background, this doesn't seem like a good candidate for changing. |
|
@exceptionfactory Could the |
|
@dan-s1 Unfortunately |
Yeah I realize. I thought it might have been included as a dependency and you would have to still add some code to produce a string output. |
|
@exceptionfactory If we still wanted to pursue something like this where the message is more expressive about the time frame, is there something you might suggest? Obviously this in a single place doesn't make a huge impact, but I bet if I did some digging I could find lots of places where having a large number of millis formatted in words would improve readability. |
Update the purge threshold output to be more human readable.
Existing output will show the value in milliseconds which can be
difficult to read quickly. Use Apache Commons lang3 to get the
threhold in a format like "30 days", "7 days 4 hours", etc.
Summary
NIFI-15989
Specifically in WriteAheadStorePartition, the maintenance task outputs the threshold as a measure of milliseconds which can be difficult to parse quickly.
Pass the value of the field
olderThanthat's passed topurgeOldEventsthrough the Apache commonsDurationFormatUtils.formatDurationWordsto get the output in a more human readable format. e.g.:Pulled in Apache Commons lang3 into Persistent Provenance Repository module. It was already in test scope, now it is additionally in compile.
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000VerifiedstatusPull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
./mvnw clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation