Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion apps/price_pusher/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class Controller {
}

if (this.metrics && targetLatestPrice && sourceLatestPrice) {
this.metrics.updatePriceDelay(
this.metrics.updateTimestamps(
priceId,
alias,
targetLatestPrice.publishTime,
Expand Down
42 changes: 32 additions & 10 deletions apps/price_pusher/src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export class PricePusherMetrics {
public lastPublishedTime: Gauge<string>;
public priceUpdateAttempts: Counter<string>;
public priceFeedsTotal: Gauge<string>;
public priceUpdateDelay: Gauge<string>;
public sourceTimestamp: Gauge<string>;
public targetTimestamp: Gauge<string>;
public configuredTimeDifference: Gauge<string>;
// Wallet metrics
public walletBalance: Gauge<string>;

Expand Down Expand Up @@ -47,9 +49,23 @@ 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)",
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],
});
Expand Down Expand Up @@ -141,19 +157,25 @@ export class PricePusherMetrics {
this.priceFeedsTotal.set(count);
}

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

Expand Down
Loading