Skip to content

Commit

Permalink
Rename query to queryUsage to improve readability.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbruens committed May 21, 2024
1 parent e21ba20 commit 87800fa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/shadowbox/server/shared_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class PrometheusUsageMetrics implements UsageMetrics {

constructor(private prometheusClient: PrometheusClient) {}

private async query(metric: string, deltaSecs: number): Promise<PrometheusQueryResult> {
private async queryUsage(metric: string, deltaSecs: number): Promise<PrometheusQueryResult> {
const query = `
sum(increase(${metric}[${deltaSecs}s]))
by (${PROMETHEUS_COUNTRY_LABEL}, ${PROMETHEUS_ASN_LABEL})
Expand All @@ -115,8 +115,8 @@ export class PrometheusUsageMetrics implements UsageMetrics {
const timeDeltaSecs = Math.round((Date.now() - this.resetTimeMs) / 1000);
const [dataBytesResult, tunnelTimeResult] = await Promise.all([
// We measure the traffic to and from the target, since that's what we are protecting.
this.query('shadowsocks_data_bytes_per_location{dir=~"p>t|p<t"}', timeDeltaSecs),
this.query('shadowsocks_tunnel_time_seconds_per_location', timeDeltaSecs),
this.queryUsage('shadowsocks_data_bytes_per_location{dir=~"p>t|p<t"}', timeDeltaSecs),
this.queryUsage('shadowsocks_tunnel_time_seconds_per_location', timeDeltaSecs),
]);

// We join the bytes and tunneltime metrics together by location (i.e. country and ASN).
Expand Down

0 comments on commit 87800fa

Please sign in to comment.