Skip to content

Commit

Permalink
Separate meta file
Browse files Browse the repository at this point in the history
  • Loading branch information
beothorn committed Nov 5, 2024
1 parent f51ad83 commit d042073
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,22 @@ public static void premainInternal(
}

Runtime.getRuntime().addShutdownHook(new Thread(() -> {
writeSnapshotToFile(snapshotDirectory, executionMetadataFormatted, new DebugListener());
writeSnapshotToFile(snapshotDirectory, new DebugListener());
}));


String content = "var executionMetadata = "+ executionMetadataFormatted +";\n";
File metaFile = new File(snapshotDirectory, "meta.js");
try (FileWriter fw = new FileWriter(metaFile)) {
fw.write(content);
fw.flush();
} catch (IOException e) {
throw new RuntimeException(e);
}

Thread snapshotThread = new Thread(() -> {
while (true) {
writeSnapshotToFile(snapshotDirectory,executionMetadataFormatted, new DebugListener());
writeSnapshotToFile(snapshotDirectory, new DebugListener());
try {
//noinspection BusyWait
Thread.sleep(SAVE_SNAPSHOT_INTERVAL_MILLIS);
Expand Down Expand Up @@ -452,7 +462,6 @@ public static String getExecutionMetadataAsJson(

private static void writeSnapshotToFile(
File snapshotDirectory,
String executionMetadataFormatted,
DebugListener debugListener
) {
fileWriteLock.lock();
Expand All @@ -470,8 +479,7 @@ private static void writeSnapshotToFile(
raf.close();
} else {
try (FileWriter fw = new FileWriter(dataFile)) {
String content = "var executionMetadata = "+ executionMetadataFormatted +";\n" +
"var data = [" + oldCallStack + ",\n];";
String content = "var data = [" + oldCallStack + ",\n];";
fw.write(content);
fw.flush();
} catch (IOException e) {
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/com/github/beothorn/agent/data.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/main/resources/com/github/beothorn/agent/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ <h1 class="threadName">Search</h1>
</div>
<div id="charts"></div>
<script type="text/javascript" src="stackignite.js"></script>
<script type="text/javascript" src="meta.js"></script>
<script type="text/javascript" src="data.js"></script>
<script type="text/javascript" src="code.js"></script>
<script type="text/javascript" src="ui.js"></script>
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/com/github/beothorn/agent/meta.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d042073

Please sign in to comment.