feat(db): enhance PostgreSQL statistics monitoring and error handling
CI / changes (push) Successful in 8s
CI / commitlint (push) Has been skipped
CI / openapi (push) Has been skipped
CI / web (push) Successful in 30s
CI / go (push) Failing after 24s
CI / bird2 (push) Has been skipped
CI / release (push) Has been skipped
CI / changes (push) Successful in 8s
CI / commitlint (push) Has been skipped
CI / openapi (push) Has been skipped
CI / web (push) Successful in 30s
CI / go (push) Failing after 24s
CI / bird2 (push) Has been skipped
CI / release (push) Has been skipped
Updated the PostgreSQL monitoring service to improve handling of `pg_stat_statements` availability. Introduced a new method to check if the extension is queryable and updated the response structure to include availability status and hints. Enhanced the documentation to clarify the requirements for enabling `pg_stat_statements`. Adjusted related components to reflect these changes, ensuring better user feedback in the monitoring interface.
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
package pgmonitor
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
)
|
||||
|
||||
func TestClampLimit(t *testing.T) {
|
||||
if clampLimit(0, 20, 100) != 20 {
|
||||
@@ -31,3 +36,13 @@ func TestNewServiceNilPool(t *testing.T) {
|
||||
t.Fatal("expected nil service")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsPgStatStatementsUnavailable(t *testing.T) {
|
||||
err := &pgconn.PgError{Code: "55000", Message: "pg_stat_statements must be loaded via shared_preload_libraries"}
|
||||
if !isPgStatStatementsUnavailable(err) {
|
||||
t.Fatal("55000")
|
||||
}
|
||||
if isPgStatStatementsUnavailable(errors.New("other")) {
|
||||
t.Fatal("unrelated")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user