Skip to content

Commit d042073

Browse files
committed
Separate meta file
1 parent f51ad83 commit d042073

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

src/main/java/com/github/beothorn/agent/MethodInstrumentationAgent.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,22 @@ public static void premainInternal(
230230
}
231231

232232
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
233-
writeSnapshotToFile(snapshotDirectory, executionMetadataFormatted, new DebugListener());
233+
writeSnapshotToFile(snapshotDirectory, new DebugListener());
234234
}));
235235

236+
237+
String content = "var executionMetadata = "+ executionMetadataFormatted +";\n";
238+
File metaFile = new File(snapshotDirectory, "meta.js");
239+
try (FileWriter fw = new FileWriter(metaFile)) {
240+
fw.write(content);
241+
fw.flush();
242+
} catch (IOException e) {
243+
throw new RuntimeException(e);
244+
}
245+
236246
Thread snapshotThread = new Thread(() -> {
237247
while (true) {
238-
writeSnapshotToFile(snapshotDirectory,executionMetadataFormatted, new DebugListener());
248+
writeSnapshotToFile(snapshotDirectory, new DebugListener());
239249
try {
240250
//noinspection BusyWait
241251
Thread.sleep(SAVE_SNAPSHOT_INTERVAL_MILLIS);
@@ -452,7 +462,6 @@ public static String getExecutionMetadataAsJson(
452462

453463
private static void writeSnapshotToFile(
454464
File snapshotDirectory,
455-
String executionMetadataFormatted,
456465
DebugListener debugListener
457466
) {
458467
fileWriteLock.lock();
@@ -470,8 +479,7 @@ private static void writeSnapshotToFile(
470479
raf.close();
471480
} else {
472481
try (FileWriter fw = new FileWriter(dataFile)) {
473-
String content = "var executionMetadata = "+ executionMetadataFormatted +";\n" +
474-
"var data = [" + oldCallStack + ",\n];";
482+
String content = "var data = [" + oldCallStack + ",\n];";
475483
fw.write(content);
476484
fw.flush();
477485
} catch (IOException e) {

src/main/resources/com/github/beothorn/agent/data.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/resources/com/github/beothorn/agent/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ <h1 class="threadName">Search</h1>
3737
</div>
3838
<div id="charts"></div>
3939
<script type="text/javascript" src="stackignite.js"></script>
40+
<script type="text/javascript" src="meta.js"></script>
4041
<script type="text/javascript" src="data.js"></script>
4142
<script type="text/javascript" src="code.js"></script>
4243
<script type="text/javascript" src="ui.js"></script>

src/main/resources/com/github/beothorn/agent/meta.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)