Skip to content

Commit 0e10eef

Browse files
author
Richard Patel
committed
add pyth_aggregated_slot metric
1 parent 1164151 commit 0e10eef

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func main() {
105105
log.Info("Listing all products")
106106
productCache, products, err := discoverProducts(initContext, client)
107107
if err != nil {
108-
log.Fatal("Failed to list products")
108+
log.Fatal("Failed to list products", zap.Error(err))
109109
}
110110
if len(allPublishers) == 0 {
111111
log.Info("Listing all publishers")
@@ -193,7 +193,7 @@ func main() {
193193

194194
if len(allPublishers) > 0 {
195195
// Scrape publisher balances.
196-
balances := newBalanceScraper(publishKeys.pubkeys, *rpcURL, log.Named("balances"))
196+
balances := newBalanceScraper(allPublishers, *rpcURL, log.Named("balances"))
197197
metrics.Registry.MustRegister(balances)
198198

199199
// Create tx tailer.

metrics/metrics.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ var (
7171
Name: "aggregated_conf_amount",
7272
Help: "Last aggregated conf of Pyth product",
7373
}, []string{labelProduct, labelSymbol})
74+
AggSlot = factory.NewGaugeVec(prometheus.GaugeOpts{
75+
Namespace: Namespace,
76+
Subsystem: SubsystemOracle,
77+
Name: "aggregated_slot",
78+
Help: "Last observed slot for Pyth product",
79+
}, []string{labelProduct, labelSymbol})
7480
AggStatus = factory.NewGaugeVec(prometheus.GaugeOpts{
7581
Namespace: Namespace,
7682
Subsystem: SubsystemOracle,

price.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ func (p *priceScraper) aggregate(product *solana.PublicKey, agg *pyth.PriceInfo,
7070
metrics.AggConf.
7171
WithLabelValues(productStr, symbol).
7272
Set(float64(agg.Conf) * decimals)
73+
metrics.AggSlot.
74+
WithLabelValues(productStr, symbol).
75+
Set(float64(agg.PubSlot))
7376
metrics.AggStatus.
7477
WithLabelValues(productStr, symbol).
7578
Set(float64(agg.Status))

txs.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ func (s *txScraper) pollOne(ctx context.Context, wg *sync.WaitGroup, tailer *txT
8383
defer wg.Done()
8484
for {
8585
isEnd, err := tailer.poll(ctx)
86-
if isEnd {
87-
break
88-
}
8986
if err != nil {
9087
s.log.Warn("Failed to poll account txs", zap.Error(err))
9188
}
89+
if isEnd {
90+
break
91+
}
9292
}
9393
}
9494

@@ -111,6 +111,9 @@ func newTxTailer(scraper *txScraper, pubkey solana.PublicKey) *txTailer {
111111
}
112112

113113
func (t *txTailer) refreshLastSig(ctx context.Context) error {
114+
t.log.Debug("Getting latest sig",
115+
zap.String("publisher", t.pubkeyStr))
116+
114117
oneInt := 1
115118
sigs, err := t.rpc.GetSignaturesForAddressWithOpts(ctx, t.pubkey, &rpc.GetSignaturesForAddressOpts{
116119
Limit: &oneInt,
@@ -121,10 +124,17 @@ func (t *txTailer) refreshLastSig(ctx context.Context) error {
121124
metrics.RpcRequestsTotal.Inc()
122125

123126
if len(sigs) == 0 {
127+
t.log.Debug("Publisher has not sent any txs yet",
128+
zap.String("publisher", t.pubkeyStr))
124129
return nil // empty account
125130
}
126131
t.lastSlot = sigs[0].Slot
127132
t.lastSig = sigs[0].Signature
133+
134+
t.log.Debug("Tailing txs starting at",
135+
zap.String("publisher", t.pubkeyStr),
136+
zap.Stringer("start_sig", t.lastSig))
137+
128138
return nil
129139
}
130140

0 commit comments

Comments
 (0)