Skip to content

Commit

Permalink
chore: remove lastConnected property and update OpenAPI spec (#1639)
Browse files Browse the repository at this point in the history
* chore: remove `lastConnected` property

* Update OpenAPI spec.
  • Loading branch information
sbruens authored Feb 14, 2025
1 parent 2cc12e0 commit 34b5e7a
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 28 deletions.
90 changes: 69 additions & 21 deletions src/shadowbox/server/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,46 +146,94 @@ paths:
type: object
properties:
server:
type: array
items:
type: object
properties:
location:
type: string
asn:
type: number
asOrg:
type: string
tunnelTime:
type: object
properties:
seconds:
type: number
dataTransferred:
type: object
properties:
tunnelTime:
type: object
properties:
seconds:
type: number
dataTransferred:
type: object
properties:
bytes:
type: number
bandwidth:
type: object
properties:
current:
type: object
properties:
data:
type: object
properties:
bytes:
type: number
timestamp:
type: integer
peak:
type: object
properties:
data:
type: object
properties:
bytes:
type: number
timestamp:
type: integer
locations:
type: array
items:
type: object
properties:
bytes:
location:
type: string
asn:
type: number
asOrg:
type: string
tunnelTime:
type: object
properties:
seconds:
type: number
dataTransferred:
type: object
properties:
bytes:
type: number
accessKeys:
type: array
items:
type: object
properties:
accessKeyId:
type: string
type: integer
tunnelTime:
type: object
properties:
seconds:
seconds:
type: number
dataTransferred:
type: object
properties:
bytes:
bytes:
type: number
connection:
type: object
properties:
lastTrafficSeen:
type: number
peakDeviceCount:
type: object
properties:
data:
type: integer
timestamp:
type: integer
examples:
'0':
value: '{"server":[{"location":"US","asn":null,"asOrg":null,"tunnelTime":{"seconds":100},"dataTransferred":{"bytes":100}}],"accessKeys":[{"accessKeyId":"0","tunnelTime":{"seconds":100},"dataTransferred":{"bytes":100}}]}'
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}}}]}'
/name:
put:
description: Renames the server
Expand Down
3 changes: 0 additions & 3 deletions src/shadowbox/server/manager_metrics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ describe('PrometheusManagerMetrics', () => {
"seconds": 1000
},
"connection": {
"lastConnected": 1738959398,
"lastTrafficSeen": 1739284734,
"peakDeviceCount": {
"data": 4,
Expand Down Expand Up @@ -389,7 +388,6 @@ describe('PrometheusManagerMetrics', () => {
"seconds": 1000
},
"connection": {
"lastConnected": null,
"lastTrafficSeen": null,
"peakDeviceCount": {
"data": 0,
Expand All @@ -406,7 +404,6 @@ describe('PrometheusManagerMetrics', () => {
"seconds": 0
},
"connection": {
"lastConnected": 1738959398,
"lastTrafficSeen": 1738959398,
"peakDeviceCount": {
"data": 4,
Expand Down
4 changes: 0 additions & 4 deletions src/shadowbox/server/manager_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ interface TimedData<T> {
}

interface ConnectionStats {
lastConnected: number | null;
lastTrafficSeen: number | null;
peakDeviceCount: TimedData<number>;
}
Expand Down Expand Up @@ -211,8 +210,6 @@ export class PrometheusManagerMetrics implements ManagerMetrics {
}
for (const result of tunnelTimeByAccessKeyRange.result) {
const entry = getServerMetricsAccessKeyEntry(accessKeyMap, result.metric);
const lastConnected = findLastNonZero(result.values ?? []);
entry.connection.lastConnected = lastConnected ? Math.min(now, lastConnected[0]) : null;
const peakTunnelTimeSec = findPeak(result.values ?? []);
if (peakTunnelTimeSec !== null) {
const peakValue = parseFloat(peakTunnelTimeSec[1]);
Expand Down Expand Up @@ -268,7 +265,6 @@ function getServerMetricsAccessKeyEntry(
dataTransferred: {bytes: 0},
tunnelTime: {seconds: 0},
connection: {
lastConnected: null,
lastTrafficSeen: null,
peakDeviceCount: {
data: 0,
Expand Down

0 comments on commit 34b5e7a

Please sign in to comment.