瀏覽代碼

Prefix metrics with service name

Ali Behjati 3 年之前
父節點
當前提交
f509dad18d
共有 2 個文件被更改,包括 9 次插入7 次删除
  1. 1 1
      third_party/pyth/price-service/src/index.ts
  2. 8 6
      third_party/pyth/price-service/src/promClient.ts

+ 1 - 1
third_party/pyth/price-service/src/index.ts

@@ -21,7 +21,7 @@ setDefaultWasm("node");
 initLogger({logLevel: process.env.LOG_LEVEL});
 
 const promClient = new PromClient({
-  name: "pyth_relay",
+  name: "price_service",
   port: parseInt(envOrErr("PROM_PORT"))
 });
 

+ 8 - 6
third_party/pyth/price-service/src/promClient.ts

@@ -8,29 +8,31 @@ import { logger } from "./logging";
 // 2) Create a method to set the metric to a value (such as `incIncoming` function below)
 // 3) Register the metric using `register.registerMetric` function.
 
+const SERVICE_PREFIX = "price_service_";
+
 export class PromClient {
   private register = new client.Registry();
   private collectDefaultMetrics = client.collectDefaultMetrics;
 
   // Actual metrics
   private receivedVaaCounter = new client.Counter({
-    name: "VAAs_received",
+    name: SERVICE_PREFIX + "VAAs_received",
     help: "number of Pyth VAAs received",
   });
   private apiLatestVaaRequestsCounter = new client.Counter({
-    name: "api_latest_vaa_requests_received",
+    name: SERVICE_PREFIX + "api_latest_vaa_requests_received",
     help: "Number of requests for latest vaa of a price feed"
   });
   private apiLatestVaaNotFoundResponseCounter = new client.Counter({
-    name: "api_latest_vaa_not_found_response",
+    name: SERVICE_PREFIX + "api_latest_vaa_not_found_response",
     help: "Number of not found responses for latest vaa of a price feed request"
   });
   private apiLatestVaaSuccessResponseCounter = new client.Counter({
-    name: "api_latest_vaa_not_found",
+    name: SERVICE_PREFIX + "api_latest_vaa_not_found",
     help: "Number of successful responses for latest vaa of a price feed request"
   });
   private apiLatestVaaFreshnessHistogram = new client.Histogram({
-    name: "api_latest_vaa_freshness",
+    name: SERVICE_PREFIX + "api_latest_vaa_freshness",
     help: "Freshness time of Vaa (time difference of Vaa and request time)",
     buckets: [1, 5, 10, 15, 30, 60, 120, 180]
   });
@@ -49,7 +51,7 @@ export class PromClient {
     this.register.setDefaultLabels({
       app: config.name,
     });
-    this.collectDefaultMetrics({ register: this.register });
+    this.collectDefaultMetrics({ register: this.register, prefix: SERVICE_PREFIX });
     // Register each metric
     this.register.registerMetric(this.receivedVaaCounter);
     this.register.registerMetric(this.apiLatestVaaRequestsCounter);