[dbsql] [ffapi] DB Stats and Metrics#205
Closed
onelapahead wants to merge 8 commits intohyperledger:externalize-tag-handlerfrom
Closed
[dbsql] [ffapi] DB Stats and Metrics#205onelapahead wants to merge 8 commits intohyperledger:externalize-tag-handlerfrom
onelapahead wants to merge 8 commits intohyperledger:externalize-tag-handlerfrom
Conversation
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
EnriqueL8
reviewed
Jan 9, 2026
Contributor
EnriqueL8
left a comment
There was a problem hiding this comment.
Thanks @onelapahead - this is great!
A few comments
pkg/dbsql/metrics.go
Outdated
| opts.dbName = "default" | ||
| } | ||
|
|
||
| metricsRegistry.MustRegisterCollector(collectors.NewDBStatsCollector(db, opts.dbName)) |
Contributor
There was a problem hiding this comment.
Info on stats https://pkg.go.dev/database/sql#DBStats
pkg/ffapi/apiserver.go
Outdated
| as.MetricsRegistry.MustRegisterCollector(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{})) | ||
| as.MetricsRegistry.MustRegisterCollector(collectors.NewGoCollector()) | ||
| } | ||
| as.MetricsRegistry.MustRegisterCollector(collectors.NewBuildInfoCollector()) |
Contributor
There was a problem hiding this comment.
Important comment on this collector:
The labels will only have meaningful values if the binary is built with Go module support and from source code retrieved from the source repository (rather than the local file system).
Contributor
Author
There was a problem hiding this comment.
Yeah debatable if we want this..
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
EnriqueL8
reviewed
Apr 8, 2026
Contributor
EnriqueL8
left a comment
There was a problem hiding this comment.
Looks good - just one comment here
| } | ||
| metricsRegistry = _metricsRegistry | ||
|
|
||
| metricsManager, err = metricsRegistry.NewMetricsManagerForSubsystem(ctx, subsystem) |
Contributor
There was a problem hiding this comment.
should the subsystem name be configurable?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Go metrics can be useful when needing to understand heap usage and how much GC is consuming resources.UPDATE: go metrics were already enabled, we just instead enabled build info metrics and have ffapi tests to ensure the metrics endpoint works as expected.DB metrics are in two forms:
Stats()from*sql.DBwith basic gauges around conn settings and pool usageSimilar to
ffresty, there's then a global func for clients to enable DB metrics, ensuring all initialized databases in a process are metered by the collector and instrumentation.