diff --git a/src/shadowbox/server/shared_metrics.ts b/src/shadowbox/server/shared_metrics.ts index e0a146ec..24659258 100644 --- a/src/shadowbox/server/shared_metrics.ts +++ b/src/shadowbox/server/shared_metrics.ts @@ -13,8 +13,6 @@ // limitations under the License. -import * as prometheus from 'prom-client'; - import {Clock} from '../infrastructure/clock'; import * as follow_redirects from '../infrastructure/follow_redirects'; import {JsonConfig} from '../infrastructure/json_config'; @@ -62,11 +60,7 @@ export interface UsageMetrics { reset(); } -export interface UsageMetricsWriter { - writeBytesTransferred(accessKeyId: AccessKeyId, numBytes: number, countries: string[]); -} - -// Writes usage metrics to Prometheus. +// Reads data usage metrics from Prometheus. export class PrometheusUsageMetrics implements UsageMetrics { private resetTimeMs: number = Date.now(); @@ -75,9 +69,8 @@ export class PrometheusUsageMetrics implements UsageMetrics { async getUsage(): Promise { const timeDeltaSecs = Math.round((Date.now() - this.resetTimeMs) / 1000); // We measure the traffic to and from the target, since that's what we are protecting. - // TODO: remove >p< once the ss-libev support is gone. - const result = await this.prometheusClient.query( - `sum(increase(shadowsocks_data_bytes{dir=~">p<|p>t|pt|pp<', '', countries.join(','), '', accessKeyId).inc(inboundBytes); - } - }; -} - export interface MetricsCollectorClient { collectMetrics(reportJson: HourlyServerMetricsReportJson): Promise; } @@ -153,12 +131,10 @@ export class OutlineSharedMetricsPublisher implements SharedMetricsPublisher { // toMetricsId: maps Access key ids to metric ids // metricsUrl: where to post the metrics constructor( - private clock: Clock, - private serverConfig: JsonConfig, + private clock: Clock, private serverConfig: JsonConfig, usageMetrics: UsageMetrics, private toMetricsId: (accessKeyId: AccessKeyId) => AccessKeyMetricsId, - private metricsCollector: MetricsCollectorClient, - ) { + private metricsCollector: MetricsCollectorClient) { // Start timer this.reportStartTimestampMs = this.clock.now();