Skip to content

Commit 34b5e7a

Browse files
authored
chore: remove lastConnected property and update OpenAPI spec (#1639)
* chore: remove `lastConnected` property * Update OpenAPI spec.
1 parent 2cc12e0 commit 34b5e7a

File tree

3 files changed

+69
-28
lines changed

3 files changed

+69
-28
lines changed

src/shadowbox/server/api.yml

Lines changed: 69 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -146,46 +146,94 @@ paths:
146146
type: object
147147
properties:
148148
server:
149-
type: array
150-
items:
151-
type: object
152-
properties:
153-
location:
154-
type: string
155-
asn:
156-
type: number
157-
asOrg:
158-
type: string
159-
tunnelTime:
160-
type: object
161-
properties:
162-
seconds:
163-
type: number
164-
dataTransferred:
149+
type: object
150+
properties:
151+
tunnelTime:
152+
type: object
153+
properties:
154+
seconds:
155+
type: number
156+
dataTransferred:
157+
type: object
158+
properties:
159+
bytes:
160+
type: number
161+
bandwidth:
162+
type: object
163+
properties:
164+
current:
165+
type: object
166+
properties:
167+
data:
168+
type: object
169+
properties:
170+
bytes:
171+
type: number
172+
timestamp:
173+
type: integer
174+
peak:
175+
type: object
176+
properties:
177+
data:
178+
type: object
179+
properties:
180+
bytes:
181+
type: number
182+
timestamp:
183+
type: integer
184+
locations:
185+
type: array
186+
items:
165187
type: object
166188
properties:
167-
bytes:
189+
location:
190+
type: string
191+
asn:
168192
type: number
193+
asOrg:
194+
type: string
195+
tunnelTime:
196+
type: object
197+
properties:
198+
seconds:
199+
type: number
200+
dataTransferred:
201+
type: object
202+
properties:
203+
bytes:
204+
type: number
169205
accessKeys:
170206
type: array
171207
items:
172208
type: object
173209
properties:
174210
accessKeyId:
175-
type: string
211+
type: integer
176212
tunnelTime:
177213
type: object
178214
properties:
179-
seconds:
215+
seconds:
180216
type: number
181217
dataTransferred:
182218
type: object
183219
properties:
184-
bytes:
220+
bytes:
221+
type: number
222+
connection:
223+
type: object
224+
properties:
225+
lastTrafficSeen:
185226
type: number
227+
peakDeviceCount:
228+
type: object
229+
properties:
230+
data:
231+
type: integer
232+
timestamp:
233+
type: integer
186234
examples:
187235
'0':
188-
value: '{"server":[{"location":"US","asn":null,"asOrg":null,"tunnelTime":{"seconds":100},"dataTransferred":{"bytes":100}}],"accessKeys":[{"accessKeyId":"0","tunnelTime":{"seconds":100},"dataTransferred":{"bytes":100}}]}'
236+
value: '{"server":{"tunnelTime":{"seconds":100},"dataTransferred":{"bytes":100},"bandwidth": {"current": {"data": {"bytes": 10},"timestamp": 1739284734},"peak": {"data": {"bytes": 80},"timestamp": 1738959398}},"locations": [{"location": "US","asn": null,"asOrg": null,"dataTransferred": {"bytes": 100},"tunnelTime": {"seconds": 100}}]},"accessKeys":[{"accessKeyId":0,"tunnelTime":{"seconds":100},"dataTransferred":{"bytes":100},"connection": {"lastTrafficSeen": 1739284734,"peakDeviceCount": {"data": 4,"timestamp": 1738959398}}}]}'
189237
/name:
190238
put:
191239
description: Renames the server

src/shadowbox/server/manager_metrics.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ describe('PrometheusManagerMetrics', () => {
202202
"seconds": 1000
203203
},
204204
"connection": {
205-
"lastConnected": 1738959398,
206205
"lastTrafficSeen": 1739284734,
207206
"peakDeviceCount": {
208207
"data": 4,
@@ -389,7 +388,6 @@ describe('PrometheusManagerMetrics', () => {
389388
"seconds": 1000
390389
},
391390
"connection": {
392-
"lastConnected": null,
393391
"lastTrafficSeen": null,
394392
"peakDeviceCount": {
395393
"data": 0,
@@ -406,7 +404,6 @@ describe('PrometheusManagerMetrics', () => {
406404
"seconds": 0
407405
},
408406
"connection": {
409-
"lastConnected": 1738959398,
410407
"lastTrafficSeen": 1738959398,
411408
"peakDeviceCount": {
412409
"data": 4,

src/shadowbox/server/manager_metrics.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ interface TimedData<T> {
3535
}
3636

3737
interface ConnectionStats {
38-
lastConnected: number | null;
3938
lastTrafficSeen: number | null;
4039
peakDeviceCount: TimedData<number>;
4140
}
@@ -211,8 +210,6 @@ export class PrometheusManagerMetrics implements ManagerMetrics {
211210
}
212211
for (const result of tunnelTimeByAccessKeyRange.result) {
213212
const entry = getServerMetricsAccessKeyEntry(accessKeyMap, result.metric);
214-
const lastConnected = findLastNonZero(result.values ?? []);
215-
entry.connection.lastConnected = lastConnected ? Math.min(now, lastConnected[0]) : null;
216213
const peakTunnelTimeSec = findPeak(result.values ?? []);
217214
if (peakTunnelTimeSec !== null) {
218215
const peakValue = parseFloat(peakTunnelTimeSec[1]);
@@ -268,7 +265,6 @@ function getServerMetricsAccessKeyEntry(
268265
dataTransferred: {bytes: 0},
269266
tunnelTime: {seconds: 0},
270267
connection: {
271-
lastConnected: null,
272268
lastTrafficSeen: null,
273269
peakDeviceCount: {
274270
data: 0,

0 commit comments

Comments
 (0)