1
0
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:
Ulysse Couturier
2026-10-20 19:26:13 +02:00
parent 692c3c07e0
commit fe15f96876
4 changed files with 6 additions and 2 deletions

View File

@@ -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 {

View File

@@ -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),

View File

@@ -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,

View File

@@ -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")
}
}