You've already forked mysqld_exporter
mirror of
https://github.com/prometheus/mysqld_exporter.git
synced 2026-10-23 08:48:59 +03:00
Align schema_size collector with runtime config refactor
Signed-off-by: Ulysse Couturier <ulysse.couturier@ovhcloud.com>
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/mysqld_exporter/config"
|
||||
)
|
||||
|
||||
const schemaSizeQuery = `
|
||||
@@ -43,7 +44,7 @@ var (
|
||||
)
|
||||
|
||||
// ScrapeSchemaSize collects from `information_schema.tables` aggregated by schema.
|
||||
type ScrapeSchemaSize struct{}
|
||||
type ScrapeSchemaSize config.EmptyConfig
|
||||
|
||||
// Name of the Scraper. Should be unique.
|
||||
func (ScrapeSchemaSize) Name() string {
|
||||
|
||||
@@ -95,6 +95,7 @@ func AllScrapers(cfg config.Config) []Scraper {
|
||||
ScrapeProcesslist(cfg.InfoSchemaProcesslist),
|
||||
ScrapeUser(cfg.MysqlUser),
|
||||
ScrapeTableSchema(cfg.InfoSchemaTables),
|
||||
ScrapeSchemaSize(emptyConfig),
|
||||
ScrapeInfoSchemaInnodbTablespaces(emptyConfig),
|
||||
ScrapeInnodbMetrics(emptyConfig),
|
||||
ScrapeInnodbTrx(emptyConfig),
|
||||
|
||||
@@ -187,6 +187,7 @@ func DefaultCollectorConfig() map[string]bool {
|
||||
"info_schema.processlist": false,
|
||||
"mysql.user": false,
|
||||
"info_schema.tables": false,
|
||||
"info_schema.schema_size": false,
|
||||
"info_schema.innodb_tablespaces": false,
|
||||
"info_schema.innodb_metrics": false,
|
||||
"info_schema.innodb_trx": false,
|
||||
|
||||
@@ -317,7 +317,8 @@ func TestSchemaSizeCollectorRegistration(t *testing.T) {
|
||||
if got := scraper.Name(); got != "info_schema.schema_size" {
|
||||
t.Fatalf("collector name = %q", got)
|
||||
}
|
||||
if enabled, exists := scrapers[scraper]; !exists || enabled {
|
||||
cfg := config.NewConfigWithDefaults()
|
||||
if enabled, exists := cfg.Collectors[scraper.Name()]; !exists || enabled {
|
||||
t.Fatal("schema size collector must be registered and disabled by default")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user