Skip to content

[dbsql] [ffapi] DB Stats and Metrics#205

Closed
onelapahead wants to merge 8 commits intohyperledger:externalize-tag-handlerfrom
kaleido-io:go-and-db-metrics
Closed

[dbsql] [ffapi] DB Stats and Metrics#205
onelapahead wants to merge 8 commits intohyperledger:externalize-tag-handlerfrom
kaleido-io:go-and-db-metrics

Conversation

@onelapahead
Copy link
Copy Markdown
Contributor

@onelapahead onelapahead commented Jan 8, 2026

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:

  1. stats collector wraps Stats() from *sql.DB with basic gauges around conn settings and pool usage
  2. instrumentation of all operations and transactions

Similar 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.

Signed-off-by: hfuss <hayden.fuss@kaleido.io>
@onelapahead onelapahead requested a review from a team as a code owner January 8, 2026 19:52
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
Copy link
Copy Markdown
Contributor

@EnriqueL8 EnriqueL8 left a comment

Choose a reason for hiding this comment

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

Thanks @onelapahead - this is great!

A few comments

opts.dbName = "default"
}

metricsRegistry.MustRegisterCollector(collectors.NewDBStatsCollector(db, opts.dbName))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

as.MetricsRegistry.MustRegisterCollector(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}))
as.MetricsRegistry.MustRegisterCollector(collectors.NewGoCollector())
}
as.MetricsRegistry.MustRegisterCollector(collectors.NewBuildInfoCollector())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah debatable if we want this..

@onelapahead onelapahead marked this pull request as draft March 9, 2026 16:04
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>
@onelapahead onelapahead changed the base branch from main to externalize-tag-handler April 5, 2026 19:16
@onelapahead onelapahead marked this pull request as ready for review April 5, 2026 19:22
Signed-off-by: hfuss <hayden.fuss@kaleido.io>
@onelapahead onelapahead changed the title [dbsql] [ffapi] Metrics for Go and DB Stats [dbsql] [ffapi] DB Stats and Metrics Apr 7, 2026
Copy link
Copy Markdown
Contributor

@EnriqueL8 EnriqueL8 left a comment

Choose a reason for hiding this comment

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

Looks good - just one comment here

}
metricsRegistry = _metricsRegistry

metricsManager, err = metricsRegistry.NewMetricsManagerForSubsystem(ctx, subsystem)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should the subsystem name be configurable?

@EnriqueL8 EnriqueL8 deleted the branch hyperledger:externalize-tag-handler April 9, 2026 11:33
@EnriqueL8 EnriqueL8 closed this Apr 9, 2026
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.

2 participants