Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apps/price_pusher/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ export class Controller {
);
}

if (this.metrics && targetLatestPrice && sourceLatestPrice) {
this.metrics.updatePriceDelay(
priceId,
alias,
targetLatestPrice.publishTime,
sourceLatestPrice.publishTime,
priceConfig.timeDifference,
);
}

const priceShouldUpdate = shouldUpdate(
priceConfig,
sourceLatestPrice,
Expand Down
24 changes: 24 additions & 0 deletions apps/price_pusher/src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class PricePusherMetrics {
public lastPublishedTime: Gauge<string>;
public priceUpdateAttempts: Counter<string>;
public priceFeedsTotal: Gauge<string>;
public priceUpdateDelay: Gauge<string>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why are these string :?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are for the label names

// Wallet metrics
public walletBalance: Gauge<string>;

Expand Down Expand Up @@ -46,6 +47,13 @@ export class PricePusherMetrics {
registers: [this.registry],
});

this.priceUpdateDelay = new Gauge({
name: "pyth_price_update_delay",
help: "Delay between source and target timestamps relative to configured threshold (positive means over threshold)",
labelNames: ["price_id", "alias"],
registers: [this.registry],
});

// Wallet balance metric
this.walletBalance = new Gauge({
name: "pyth_wallet_balance",
Expand Down Expand Up @@ -133,6 +141,22 @@ export class PricePusherMetrics {
this.priceFeedsTotal.set(count);
}

// Update price delay relative to threshold
public updatePriceDelay(
priceId: string,
alias: string,
targetLatestPricePublishTime: number,
sourceLatestPricePublishTime: number,
priceConfigTimeDifference: number,
): void {
this.priceUpdateDelay.set(
{ price_id: priceId, alias },
sourceLatestPricePublishTime -
targetLatestPricePublishTime -
priceConfigTimeDifference,
);
}

// Update wallet balance
public updateWalletBalance(
walletAddress: string,
Expand Down
Loading