diff --git a/src/main/java/io/perfana/jfr/event/NativeMemoryEvent.java b/src/main/java/io/perfana/jfr/event/NativeMemoryEvent.java index 79e9f80..4a8dc8d 100644 --- a/src/main/java/io/perfana/jfr/event/NativeMemoryEvent.java +++ b/src/main/java/io/perfana/jfr/event/NativeMemoryEvent.java @@ -32,6 +32,8 @@ public class NativeMemoryEvent implements OnJfrEvent, JfrEventProvider { public static final String JDK_NATIVE_MEMORY_USAGE = "jdk.NativeMemoryUsage"; public static final String JDK_NATIVE_MEMORY_USAGE_TOTAL = "jdk.NativeMemoryUsageTotal"; public static final String JDK_RESIDENT_SET_SIZE = "jdk.ResidentSetSize"; + public static final String FIELD_COMMITTED = "committed"; + public static final String FIELD_RESERVED = "reserved"; private final JfrEventProcessor eventProcessor; @@ -61,28 +63,29 @@ public void onEvent(RecordedEvent event) { } private ProcessedJfrEvent processNativeMemoryUsageTotal(RecordedEvent event) { - long reservedMemory = event.getLong("reserved"); - long committedMemory = event.getLong("committed"); + long reservedMemory = event.getLong(FIELD_RESERVED); + long committedMemory = event.getLong(FIELD_COMMITTED); return ProcessedJfrEvent.of( event.getStartTime(), "memory-native-total", - "reserved", + FIELD_RESERVED, reservedMemory, - Map.of("committed", committedMemory)); + Map.of(FIELD_COMMITTED, committedMemory)); } private ProcessedJfrEvent processNativeMemoryUsage(RecordedEvent event) { - long reservedMemory = event.getLong("reserved"); - long committedMemory = event.getLong("committed"); + long reservedMemory = event.getLong(FIELD_RESERVED); + long committedMemory = event.getLong(FIELD_COMMITTED); String nmtType = event.getString("type"); return ProcessedJfrEvent.of( event.getStartTime(), "memory-native", - "reserved", + Map.of("type", nmtType), + FIELD_RESERVED, reservedMemory, - Map.of("committed", committedMemory, "type", nmtType)); + Map.of(FIELD_COMMITTED, committedMemory)); } private ProcessedJfrEvent processResidentSetSize(RecordedEvent event) { diff --git a/src/main/java/io/perfana/jfr/influx/InfluxWriterNative.java b/src/main/java/io/perfana/jfr/influx/InfluxWriterNative.java index b131881..f8e995e 100644 --- a/src/main/java/io/perfana/jfr/influx/InfluxWriterNative.java +++ b/src/main/java/io/perfana/jfr/influx/InfluxWriterNative.java @@ -109,7 +109,6 @@ public void writeMetricPoint(ProcessedJfrEvent event) { boolean useBuffer = true; - String dataToSend = key + " " + generatedFields + " " + timestampEpochNano; if (useBuffer) { @@ -125,7 +124,7 @@ public void writeMetricPoint(ProcessedJfrEvent event) { } else if (origTags.size() == 1) { Map.Entry entry = origTags.entrySet().iterator().next(); - return "," + entry.getKey() + "=" + escapeFieldForInflux(entry.getValue()); + return "," + entry.getKey() + "=" + escapeTagForInflux(entry.getValue()); } else { // tags are sorted alphabetically for better performance in InfluxDB