Skip to content

Commit e9f8038

Browse files
committed
feat: added runtime version in the traffic collector metrics and info
1 parent 521c933 commit e9f8038

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

apps/database-abstractor/src/main/java/com/akto/action/DbAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public String updateTrafficCollectorMetrics() {
372372

373373
// update heartbeat
374374
try {
375-
TrafficCollectorInfoDao.instance.updateHeartbeat(trafficCollectorMetrics.getId(), trafficCollectorMetrics.getRuntimeId());
375+
TrafficCollectorInfoDao.instance.updateHeartbeat(trafficCollectorMetrics.getId(), trafficCollectorMetrics.getRuntimeId(), trafficCollectorMetrics.getVersion());
376376
} catch (Exception e) {
377377
loggerMaker.errorAndAddToDb(e, "Error while updating heartbeat: " + e);
378378
}

libs/dao/src/main/java/com/akto/dao/traffic_collector/TrafficCollectorInfoDao.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ public void createIndicesIfAbsent() {
4747
}
4848

4949

50-
public void updateHeartbeat(String id, String runtimeId) {
50+
public void updateHeartbeat(String id, String runtimeId, String version) {
5151
instance.updateOne(
5252
Filters.eq("_id", id),
5353
Updates.combine(
5454
Updates.set(TrafficCollectorInfo.LAST_HEARTBEAT, Context.now()),
5555
Updates.setOnInsert(TrafficCollectorInfo.START_TIME, Context.now()),
56-
Updates.setOnInsert(TrafficCollectorInfo.RUNTIME_ID, runtimeId)
56+
Updates.setOnInsert(TrafficCollectorInfo.RUNTIME_ID, runtimeId),
57+
Updates.set(TrafficCollectorInfo.VERSION, version)
5758
)
5859
);
5960
}

libs/dao/src/main/java/com/akto/dto/traffic_collector/TrafficCollectorInfo.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@ public class TrafficCollectorInfo {
99
private int startTime;
1010
public static final String LAST_HEARTBEAT = "lastHeartbeat";
1111
private int lastHeartbeat;
12+
public static final String VERSION = "version";
13+
private String version;
1214

1315
public TrafficCollectorInfo() {}
1416

15-
public TrafficCollectorInfo(String id, String runtimeId, int startTime, int lastHeartbeat) {
17+
public TrafficCollectorInfo(String id, String runtimeId, int startTime, int lastHeartbeat, String version) {
1618
this.id = id;
1719
this.runtimeId = runtimeId;
1820
this.startTime = startTime;
1921
this.lastHeartbeat = lastHeartbeat;
22+
this.version = version;
2023
}
2124

2225
public String getId() {
@@ -50,4 +53,12 @@ public String getRuntimeId() {
5053
public void setRuntimeId(String runtimeId) {
5154
this.runtimeId = runtimeId;
5255
}
56+
57+
public String getVersion() {
58+
return version;
59+
}
60+
61+
public void setVersion(String version) {
62+
this.version = version;
63+
}
5364
}

libs/dao/src/main/java/com/akto/dto/traffic_collector/TrafficCollectorMetrics.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ public class TrafficCollectorMetrics {
1212
private int bucketStartEpoch;
1313
public static final String BUCKET_END_EPOCH = "bucketEndEpoch";
1414
private int bucketEndEpoch;
15+
public static final String VERSION = "version";
16+
private String version;
1517

1618

17-
public TrafficCollectorMetrics(String id, String runtimeId, Map<String, Integer> requestsCountMapPerMinute, int bucketStartEpoch, int bucketEndEpoch) {
19+
public TrafficCollectorMetrics(String id, String runtimeId, Map<String, Integer> requestsCountMapPerMinute, int bucketStartEpoch, int bucketEndEpoch, String version) {
1820
this.id = id;
1921
this.runtimeId = runtimeId;
2022
this.requestsCountMapPerMinute = requestsCountMapPerMinute;
2123
this.bucketStartEpoch = bucketStartEpoch;
2224
this.bucketEndEpoch = bucketEndEpoch;
25+
this.version = version;
2326
}
2427

2528
public TrafficCollectorMetrics() {
@@ -75,4 +78,12 @@ public String getRuntimeId() {
7578
public void setRuntimeId(String runtimeId) {
7679
this.runtimeId = runtimeId;
7780
}
81+
82+
public String getVersion() {
83+
return version;
84+
}
85+
86+
public void setVersion(String version) {
87+
this.version = version;
88+
}
7889
}

0 commit comments

Comments
 (0)