Skip to content

Commit bdac944

Browse files
committed
Add BUILD_ID tracking to metrics and error reports
Introduced `BUILD_ID` to `SimpleMetrics` for better traceability. Updated `SimpleErrorTracker` to include `BUILD_ID` in error reports.
1 parent 138784b commit bdac944

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

core/src/main/java/dev/faststats/core/SimpleErrorTracker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ public void trackError(final Throwable error) {
3535
}
3636
}
3737

38-
public JsonArray getData() {
38+
public JsonArray getData(final String buildId) {
3939
final var report = new JsonArray(reports.size());
4040

4141
reports.forEach((hash, object) -> {
4242
final var copy = object.deepCopy();
4343
copy.addProperty("hash", hash);
44+
copy.addProperty("buildId", buildId);
4445
final var count = collected.getOrDefault(hash, 1);
4546
if (count > 1) copy.addProperty("count", count);
4647
report.add(copy);

core/src/main/java/dev/faststats/core/SimpleMetrics.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public abstract class SimpleMetrics implements Metrics {
5151

5252
private final String SDK_NAME;
5353
private final String SDK_VERSION;
54+
private final String BUILD_ID;
5455

5556
{
5657
final var properties = new Properties();
@@ -60,6 +61,7 @@ public abstract class SimpleMetrics implements Metrics {
6061
}
6162
this.SDK_NAME = properties.getProperty("name", "unknown");
6263
this.SDK_VERSION = properties.getProperty("version", "unknown");
64+
this.BUILD_ID = properties.getProperty("build-id", "unknown");
6365
}
6466

6567
@Contract(mutates = "io")
@@ -278,7 +280,7 @@ protected JsonObject createData() {
278280
data.add("data", metrics);
279281

280282
getErrorTracker().map(SimpleErrorTracker.class::cast)
281-
.map(SimpleErrorTracker::getData)
283+
.map(tracker -> tracker.getData(BUILD_ID))
282284
.filter(errors -> !errors.isEmpty())
283285
.ifPresent(errors -> data.add("errors", errors));
284286
return data;

0 commit comments

Comments
 (0)