Skip to content

Commit

Permalink
Fixed timestamp consistency (#1100)
Browse files Browse the repository at this point in the history
Signed-off-by: dhoard <[email protected]>
  • Loading branch information
dhoard authored Dec 18, 2024
1 parent f288cc5 commit 0a35c0b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
package io.prometheus.jmx;

import java.lang.management.ManagementFactory;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import javax.management.MBeanServer;
import javax.management.ObjectName;

/** Class to implement JmxExampleApplication */
public class JmxExampleApplication {

private static final SimpleDateFormat SIMPLE_DATE_FORMAT =
new SimpleDateFormat("yyyy-MM-dd | HH:mm:ss.SSS", Locale.getDefault());
private static final DateTimeFormatter DATE_TIME_FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault());

/** Constructor */
private JmxExampleApplication() {
Expand Down Expand Up @@ -61,7 +61,7 @@ public static void main(String[] args) throws Exception {

System.out.printf(
"%s | %s | INFO | %s | %s%n",
SIMPLE_DATE_FORMAT.format(new Date()),
LocalDateTime.now().format(DATE_TIME_FORMATTER),
Thread.currentThread().getName(),
JmxExampleApplication.class.getName(),
"Running");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
import java.io.File;
import java.lang.instrument.Instrumentation;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

/** Class to implement JavaAgent */
public class JavaAgent {

private static final SimpleDateFormat SIMPLE_DATE_FORMAT =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault());
private static final DateTimeFormatter DATE_TIME_FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault());

private static final PrometheusRegistry DEFAULT_REGISTRY = PrometheusRegistry.defaultRegistry;

Expand Down Expand Up @@ -111,7 +111,7 @@ public static void premain(String agentArgument, Instrumentation instrumentation
private static void info(String format, Object... objects) {
System.out.printf(
"%s | %s | INFO | %s | %s%n",
SIMPLE_DATE_FORMAT.format(new Date()),
LocalDateTime.now().format(DATE_TIME_FORMATTER),
Thread.currentThread().getName(),
JavaAgent.class.getName(),
format(format, objects));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
import io.prometheus.metrics.model.registry.PrometheusRegistry;
import java.io.File;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

/** Class to implement Standalone */
public class Standalone {

private static final SimpleDateFormat SIMPLE_DATE_FORMAT =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault());
private static final DateTimeFormatter DATE_TIME_FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault());

private static final PrometheusRegistry DEFAULT_REGISTRY = PrometheusRegistry.defaultRegistry;

Expand Down Expand Up @@ -98,7 +98,7 @@ public static void main(String[] args) throws Exception {
PrometheusRegistry.defaultRegistry, file);
}

info("Running ...", httpEnabled, openTelemetryEnabled);
info("Running ...");

Thread.currentThread().join();
} catch (ConfigurationException e) {
Expand Down Expand Up @@ -143,7 +143,7 @@ private static void close(AutoCloseable autoCloseable) {
private static void info(String format, Object... objects) {
System.out.printf(
"%s | %s | INFO | %s | %s%n",
SIMPLE_DATE_FORMAT.format(new Date()),
LocalDateTime.now().format(DATE_TIME_FORMATTER),
Thread.currentThread().getName(),
Standalone.class.getName(),
format(format, objects));
Expand Down

0 comments on commit 0a35c0b

Please sign in to comment.