Skip to content

Commit 6cb1274

Browse files
authored
add a unique id for GC events so that events from a single JVM can be grouped (#1721)
1 parent 1ff5d25 commit 6cb1274

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

core/src/main/java/com/microsoft/applicationinsights/internal/profiler/GcEventMonitor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import java.lang.management.MemoryUsage;
1616
import java.util.Optional;
17+
import java.util.UUID;
1718
import java.util.concurrent.ExecutorService;
1819

1920
/**
@@ -24,6 +25,11 @@
2425
public class GcEventMonitor {
2526
private static final Logger LOGGER = LoggerFactory.getLogger(GcEventMonitor.class);
2627

28+
// a unique jvm_instance_id is needed for every restart as the gc starts again from scratch every time
29+
// the JVM is restarted, and we need to analyze single JVM execution
30+
//TODO if/when Application Insights adds a unique ID that represents a single JVM, pull that ID here
31+
private static final String JVM_INSTANCE_UID = UUID.randomUUID().toString();
32+
2733
public static class GcEventMonitorConfiguration {
2834
public final GcReportingLevel reportingLevel;
2935

@@ -106,6 +112,7 @@ private static void emitGcEvent(TelemetryClient telemetryClient, GcEventMonitorC
106112
gcEvent.getProperties().put("collector", event.getCollector().getName());
107113
gcEvent.getProperties().put("type", event.getGcCause());
108114
gcEvent.getProperties().put("action", event.getGcAction());
115+
gcEvent.getProperties().put("jvm_instance_id", JVM_INSTANCE_UID);
109116
gcEvent.getMetrics().put("id", (double) event.getId());
110117
gcEvent.getMetrics().put("duration_ms", (double) event.getDuration());
111118
gcEvent.getMetrics().put("end_time_ms", (double) event.getEndTime());

0 commit comments

Comments
 (0)