Skip to content
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

Merged
merged 6 commits into from
Oct 26, 2020

Conversation

bartekn
Copy link
Contributor

@bartekn bartekn commented Oct 21, 2020

PR Checklist

PR Structure

  • This PR has reasonably narrow scope (if not, break it down into smaller PRs).
  • This PR avoids mixing refactoring changes with feature changes (split into two PRs
    otherwise).
  • This PR's title starts with name of package that is most changed in the PR, ex.
    services/friendbot, or all or doc if the changes are broad or impact many
    packages.

Thoroughness

  • This PR adds tests for the most critical parts of the new functionality or fixes.
  • I've updated any docs (developer docs, .md
    files, etc... affected by this change). Take a look in the docs folder for a given service,
    like this one.

Release planning

  • I've updated the relevant CHANGELOG (here for Horizon) if
    needed with deprecations, added features, breaking changes, and DB schema changes.
  • I've decided if this PR requires a new major/minor version according to
    semver, or if it's mainly a patch change. The PR is targeted at the next
    release branch if it's not a patch change.

What

Export ledger stats (number of ops and changes) in /metrics. Add claimable balances to changes stats.

Close #3133.

Why

To be able to correlate slow ledger with network activitity.

@bartekn bartekn requested a review from a team October 21, 2020 18:46
@cla-bot cla-bot bot added the cla: yes label Oct 21, 2020
@@ -82,6 +95,10 @@ func (stats *StatsChangeProcessorResults) Map() map[string]interface{} {
"stats_accounts_updated": stats.AccountsUpdated,
"stats_accounts_removed": stats.AccountsRemoved,

"stats_claimable_balances_created": stats.ClaimableBalancesCreated,
"stats_claimable_balances_updated": stats.ClaimableBalancesUpdated,
"stats_claimable_balances_removed": stats.ClaimableBalancesRemoved,
Copy link
Contributor

@Shaptic Shaptic Oct 21, 2020

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?

Copy link
Contributor Author

@bartekn bartekn Oct 21, 2020

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.

Comment on lines 476 to 491

// 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)))
}

Copy link
Contributor

Choose a reason for hiding this comment

The 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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@2opremio do you have something like d6f557b in mind?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's better, yeah.

@bartekn
Copy link
Contributor Author

bartekn commented Oct 26, 2020

@2opremio @Shaptic can I have a final 👍 ?

@bartekn bartekn merged commit 118e4a0 into stellar:master Oct 26, 2020
@bartekn bartekn deleted the metrics-ledger-stats branch October 26, 2020 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ledger stats to /metrics
3 participants