RFR: 8357828: Add a timestamp to jcmd diagnostic commands
David Holmes
dholmes at openjdk.org
Mon Sep 22 05:47:20 UTC 2025
On Thu, 18 Sep 2025 14:57:44 GMT, Ivan Bereziuk <duke at openjdk.org> wrote:
> `jcmd` provides great diagnostics but many commands lack a timestamp in their output.
> Adding a timestamp to the output of some would add value for those debugging JVM data.
>
> Some diagnostic commands already provide timestamps. For example `Thread.print` already prints timestamp in a "yyyy-MM-dd HH:mm:ss" format.
>
> Adding timestamps to all diagnostic `jcmd` commands with a non-throw-away STDOUT.
>
> The exceptions are:
> * `VM.uptime` - command run with `-date` argument will also print a timestamp;
> * `VM.system_properties` - already lists timestamp
> * `Thread.dump_to_file` - the content dumped to file already has a timestamp;
> * `VM.version`
This was raised and discussed somewhere else not that long ago, but I don't recall where and it fizzled out as I recall. But I will re-raise the issues - what form should this timestamp take? Shouldn't it be configurable to allow matching with what may be presented by Unified Logging e.g. VM uptime rather than wall-clock time? The value of a timestamp on dmcd output is to allow it to be placed in chronological order relative to other output - so you need to be able to match the "timestamp" of that other output.
And rather than add timestamp printing code to each dcmd it would make more sense to me to have a global dcmd flag that says "print a timestamp" (with a given format). That way users opt-in and we don't have to remember to add this for new Dcmds.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27368#issuecomment-3317032230
More information about the serviceability-dev
mailing list