Skip to content

Commit

Permalink
partial feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellacosse committed Nov 14, 2024
1 parent b872d59 commit 97c5317
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/shadowbox/server/manager_metrics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('PrometheusManagerMetrics', () => {
metric: {
location: 'US',
asn: '49490',
asorg: 'null',
asorg: null,
},
value: [null, '1000'],
},
Expand All @@ -50,7 +50,7 @@ describe('PrometheusManagerMetrics', () => {
metric: {
location: 'US',
asn: '49490',
asorg: 'null',
asorg: null,
},
value: [null, '1000'],
},
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('PrometheusManagerMetrics', () => {
{
"location": "US",
"asn": 49490,
"asOrg": "null",
"asOrg": null,
"dataTransferred": {
"bytes": 1000
},
Expand Down
20 changes: 10 additions & 10 deletions src/shadowbox/server/manager_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ export class PrometheusManagerMetrics implements ManagerMetrics {
`sum(increase(shadowsocks_tunnel_time_seconds[${hours}h])) by (access_key)`
);

const server = [];
const tunnelTimeByLocationMap = tunnelTimeByLocation.result.reduce((map, entry) => {
map.set(
const tunnelTimeByLocationMap = new Map();
for (const entry of tunnelTimeByLocation.result) {
tunnelTimeByLocationMap.set(
`${entry.metric['location']},${entry.metric['asn']},${entry.metric['asorg']}`,
parseFloat(entry.value[1])
);
}

return map;
}, new Map());
const server = [];
for (const entry of dataTransferredByLocation.result) {
const result: ServerMetricsServerEntry = {
location: entry.metric['location'],
Expand All @@ -114,12 +114,12 @@ export class PrometheusManagerMetrics implements ManagerMetrics {
server.push(result);
}

const accessKeys = [];
const tunnelTimeByAccessKeyMap = tunnelTimeByAccessKey.result.reduce((map, entry) => {
map.set(entry.metric['access_key'], parseFloat(entry.value[1]));
const tunnelTimeByAccessKeyMap = new Map();
for (const entry of tunnelTimeByAccessKey.result) {
tunnelTimeByAccessKeyMap.set(entry.metric['access_key'], parseFloat(entry.value[1]));
}

return map;
}, new Map());
const accessKeys = [];
for (const entry of dataTransferredByAccessKey.result) {
const result: ServerMetricsAccessKeyEntry = {
accessKeyId: parseInt(entry.metric['access_key']),
Expand Down

0 comments on commit 97c5317

Please sign in to comment.