-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
services/horizon: Export ledger stats in /metrics, add claimable_balance to change stats #3148
Changes from 3 commits
29ab40a
cf68d25
36fb724
d6f557b
2a03c6b
3ade209
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ package ingest | |
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/stellar/go/ingest/ledgerbackend" | ||
|
||
"github.com/stellar/go/ingest/io" | ||
|
@@ -471,9 +473,25 @@ func (r resumeState) run(s *system) (transition, error) { | |
|
||
duration := time.Since(startTime).Seconds() | ||
s.Metrics().LedgerIngestionDuration.Observe(float64(duration)) | ||
|
||
// Update stats metrics | ||
changeStatsMap := changeStats.Map() | ||
for stat, value := range changeStatsMap { | ||
stat = strings.Replace(stat, "stats_", "change_", 1) | ||
s.Metrics().LedgerStatsCounter. | ||
With(prometheus.Labels{"type": stat}).Add(float64(value.(int64))) | ||
} | ||
|
||
ledgerTransactionStatsMap := ledgerTransactionStats.Map() | ||
for stat, value := range ledgerTransactionStatsMap { | ||
stat = strings.Replace(stat, "stats_", "ledger_", 1) | ||
s.Metrics().LedgerStatsCounter. | ||
With(prometheus.Labels{"type": stat}).Add(float64(value.(int64))) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would it be worth to factor out the metrics-updating code? (the method is already pretty large) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's better, yeah. |
||
log. | ||
WithFields(changeStats.Map()). | ||
WithFields(ledgerTransactionStats.Map()). | ||
WithFields(changeStatsMap). | ||
WithFields(ledgerTransactionStatsMap). | ||
WithFields(logpkg.F{ | ||
"sequence": ingestLedger, | ||
"duration": duration, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to extend the CB integration tests to check these new fields, or do you think unit tests are sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we have any tests for this so far. If we want to add some integration tests, I'd vote for adding this in another PR.