Skip to content

Commit 800b2f0

Browse files
committed
chore: enforce standard_conforming_strings in metric collection (#2888)
Ensure that `standard_conforming_strings` is set to `on` in every Prometheus connection transaction for metric collection. This is just in case users disable that globally. Closes #2887 Signed-off-by: Gabriele Bartolini <[email protected]> (cherry picked from commit 529185e)
1 parent e1fa353 commit 800b2f0

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎pkg/management/postgres/metrics/collector.go‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,19 @@ func createMonitoringTx(conn *sql.DB) (*sql.Tx, error) {
456456
}
457457
}()
458458

459+
// Set the application name
459460
_, err = tx.Exec("SET application_name TO cnpg_metrics_exporter")
460461
if err != nil {
461462
return nil, err
462463
}
463464

465+
// Ensure standard_conforming_strings is enforced
466+
_, err = tx.Exec("SET standard_conforming_strings TO on")
467+
if err != nil {
468+
return nil, err
469+
}
470+
471+
// Set the pg_monitor role
464472
_, err = tx.Exec("SET ROLE TO pg_monitor")
465473

466474
return tx, err

0 commit comments

Comments
 (0)