Skip to content

Commit 15ddbd0

Browse files
committed
feat(metrics): refactor price update delay metrics to use source and target timestamps
1 parent 63d7dd0 commit 15ddbd0

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

apps/price_pusher/src/controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class Controller {
6363
}
6464

6565
if (this.metrics && targetLatestPrice && sourceLatestPrice) {
66-
this.metrics.updatePriceDelay(
66+
this.metrics.updateTimestamps(
6767
priceId,
6868
alias,
6969
targetLatestPrice.publishTime,

apps/price_pusher/src/metrics.ts

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export class PricePusherMetrics {
1414
public lastPublishedTime: Gauge<string>;
1515
public priceUpdateAttempts: Counter<string>;
1616
public priceFeedsTotal: Gauge<string>;
17-
public priceUpdateDelay: Gauge<string>;
17+
public sourceTimestamp: Gauge<string>;
18+
public targetTimestamp: Gauge<string>;
19+
public configuredTimeDifference: Gauge<string>;
1820
// Wallet metrics
1921
public walletBalance: Gauge<string>;
2022

@@ -47,9 +49,23 @@ export class PricePusherMetrics {
4749
registers: [this.registry],
4850
});
4951

50-
this.priceUpdateDelay = new Gauge({
51-
name: "pyth_price_update_delay",
52-
help: "Delay between source and target timestamps relative to configured threshold (positive means over threshold)",
52+
this.sourceTimestamp = new Gauge({
53+
name: "pyth_source_timestamp",
54+
help: "Latest source chain price publish timestamp",
55+
labelNames: ["price_id", "alias"],
56+
registers: [this.registry],
57+
});
58+
59+
this.targetTimestamp = new Gauge({
60+
name: "pyth_target_timestamp",
61+
help: "Latest target chain price publish timestamp",
62+
labelNames: ["price_id", "alias"],
63+
registers: [this.registry],
64+
});
65+
66+
this.configuredTimeDifference = new Gauge({
67+
name: "pyth_configured_time_difference",
68+
help: "Configured time difference threshold between source and target chains",
5369
labelNames: ["price_id", "alias"],
5470
registers: [this.registry],
5571
});
@@ -141,19 +157,25 @@ export class PricePusherMetrics {
141157
this.priceFeedsTotal.set(count);
142158
}
143159

144-
// Update price delay relative to threshold
145-
public updatePriceDelay(
160+
// Update source, target and configured time difference timestamps
161+
public updateTimestamps(
146162
priceId: string,
147163
alias: string,
148164
targetLatestPricePublishTime: number,
149165
sourceLatestPricePublishTime: number,
150166
priceConfigTimeDifference: number,
151167
): void {
152-
this.priceUpdateDelay.set(
168+
this.sourceTimestamp.set(
169+
{ price_id: priceId, alias },
170+
sourceLatestPricePublishTime,
171+
);
172+
this.targetTimestamp.set(
173+
{ price_id: priceId, alias },
174+
targetLatestPricePublishTime,
175+
);
176+
this.configuredTimeDifference.set(
153177
{ price_id: priceId, alias },
154-
sourceLatestPricePublishTime -
155-
targetLatestPricePublishTime -
156-
priceConfigTimeDifference,
178+
priceConfigTimeDifference,
157179
);
158180
}
159181

0 commit comments

Comments
 (0)