1
1
import { Registry , Counter , Gauge } from "prom-client" ;
2
2
import express from "express" ;
3
- import { PriceInfo } from "./interface" ;
4
3
import { Logger } from "pino" ;
5
4
import { UpdateCondition } from "./price-config" ;
6
5
@@ -14,6 +13,8 @@ export class PricePusherMetrics {
14
13
public lastPublishedTime : Gauge < string > ;
15
14
public priceUpdateAttempts : Counter < string > ;
16
15
public priceFeedsTotal : Gauge < string > ;
16
+ public sourceTimestamp : Gauge < string > ;
17
+ public configuredTimeDifference : Gauge < string > ;
17
18
// Wallet metrics
18
19
public walletBalance : Gauge < string > ;
19
20
@@ -46,6 +47,20 @@ export class PricePusherMetrics {
46
47
registers : [ this . registry ] ,
47
48
} ) ;
48
49
50
+ this . sourceTimestamp = new Gauge ( {
51
+ name : "pyth_source_timestamp" ,
52
+ help : "Latest source chain price publish timestamp" ,
53
+ labelNames : [ "price_id" , "alias" ] ,
54
+ registers : [ this . registry ] ,
55
+ } ) ;
56
+
57
+ this . configuredTimeDifference = new Gauge ( {
58
+ name : "pyth_configured_time_difference" ,
59
+ help : "Configured time difference threshold between source and target chains" ,
60
+ labelNames : [ "price_id" , "alias" ] ,
61
+ registers : [ this . registry ] ,
62
+ } ) ;
63
+
49
64
// Wallet balance metric
50
65
this . walletBalance = new Gauge ( {
51
66
name : "pyth_wallet_balance" ,
@@ -68,18 +83,6 @@ export class PricePusherMetrics {
68
83
} ) ;
69
84
}
70
85
71
- // Update the last published time for a price feed
72
- public updateLastPublishedTime (
73
- priceId : string ,
74
- alias : string ,
75
- priceInfo : PriceInfo ,
76
- ) : void {
77
- this . lastPublishedTime . set (
78
- { price_id : priceId , alias } ,
79
- priceInfo . publishTime ,
80
- ) ;
81
- }
82
-
83
86
// Record a successful price update
84
87
public recordPriceUpdate (
85
88
priceId : string ,
@@ -133,6 +136,28 @@ export class PricePusherMetrics {
133
136
this . priceFeedsTotal . set ( count ) ;
134
137
}
135
138
139
+ // Update source, target and configured time difference timestamps
140
+ public updateTimestamps (
141
+ priceId : string ,
142
+ alias : string ,
143
+ targetLatestPricePublishTime : number ,
144
+ sourceLatestPricePublishTime : number ,
145
+ priceConfigTimeDifference : number ,
146
+ ) : void {
147
+ this . sourceTimestamp . set (
148
+ { price_id : priceId , alias } ,
149
+ sourceLatestPricePublishTime ,
150
+ ) ;
151
+ this . lastPublishedTime . set (
152
+ { price_id : priceId , alias } ,
153
+ targetLatestPricePublishTime ,
154
+ ) ;
155
+ this . configuredTimeDifference . set (
156
+ { price_id : priceId , alias } ,
157
+ priceConfigTimeDifference ,
158
+ ) ;
159
+ }
160
+
136
161
// Update wallet balance
137
162
public updateWalletBalance (
138
163
walletAddress : string ,
0 commit comments