1
0
mirror of https://github.com/prometheus/mysqld_exporter.git synced 2025-07-30 06:43:05 +03:00

Add the instance struct to handle connections (#859)

The intent is to use the instance struct to hold the connection
to the database as well as metadata about the instance:
- version
- flavor (mariadb or mysql)

Change is similar to prometheus-community/postgres_exporter#785

Signed-off-by: Vlad Gusev <vlad.esten@gmail.com>
This commit is contained in:
Vlad Gusev
2024-08-12 16:39:52 +03:00
committed by GitHub
parent dd8afce2a4
commit 31bc75a200
67 changed files with 267 additions and 156 deletions

View File

@ -152,10 +152,10 @@ END OF INNODB MONITOR OUTPUT
rows := sqlmock.NewRows(columns).AddRow("InnoDB", "", sample)
mock.ExpectQuery(sanitizeQuery(engineInnodbStatusQuery)).WillReturnRows(rows)
inst := &instance{db: db}
ch := make(chan prometheus.Metric)
go func() {
if err = (ScrapeEngineInnodbStatus{}).Scrape(context.Background(), db, ch, log.NewNopLogger()); err != nil {
if err = (ScrapeEngineInnodbStatus{}).Scrape(context.Background(), inst, ch, log.NewNopLogger()); err != nil {
t.Errorf("error calling function on test: %s", err)
}
close(ch)