Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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.updateTimestamps(
priceId,
alias,
targetLatestPrice.publishTime,
sourceLatestPrice.publishTime,
priceConfig.timeDifference,
);
}

const priceShouldUpdate = shouldUpdate(
priceConfig,
sourceLatestPrice,
Expand Down
46 changes: 46 additions & 0 deletions apps/price_pusher/src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export class PricePusherMetrics {
public lastPublishedTime: Gauge<string>;
public priceUpdateAttempts: Counter<string>;
public priceFeedsTotal: Gauge<string>;
public sourceTimestamp: Gauge<string>;
public targetTimestamp: Gauge<string>;
public configuredTimeDifference: Gauge<string>;
// Wallet metrics
public walletBalance: Gauge<string>;

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

this.sourceTimestamp = new Gauge({
name: "pyth_source_timestamp",
help: "Latest source chain price publish timestamp",
labelNames: ["price_id", "alias"],
registers: [this.registry],
});

this.targetTimestamp = new Gauge({
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the difference between this and lastPublishedTime ?

Copy link
Contributor Author

@cctdaniel cctdaniel Apr 28, 2025

Choose a reason for hiding this comment

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

yeah its redundant, i will remove targetTimestamp and use lastPublishedTime instead

name: "pyth_target_timestamp",
help: "Latest target chain price publish timestamp",
labelNames: ["price_id", "alias"],
registers: [this.registry],
});

this.configuredTimeDifference = new Gauge({
name: "pyth_configured_time_difference",
help: "Configured time difference threshold between source and target chains",
labelNames: ["price_id", "alias"],
registers: [this.registry],
});

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

// Update source, target and configured time difference timestamps
public updateTimestamps(
priceId: string,
alias: string,
targetLatestPricePublishTime: number,
sourceLatestPricePublishTime: number,
priceConfigTimeDifference: number,
): void {
this.sourceTimestamp.set(
{ price_id: priceId, alias },
sourceLatestPricePublishTime,
);
this.targetTimestamp.set(
{ price_id: priceId, alias },
targetLatestPricePublishTime,
);
this.configuredTimeDifference.set(
{ price_id: priceId, alias },
priceConfigTimeDifference,
);
}

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