Add SQL tracing via DENDRITE_TRACE_SQL (#968)

* Add SQL tracing via DENDRITE_TRACE_SQL

Add this to `internal/sqlutil` in preparation for #897

* Not entirely
This commit is contained in:
Kegsay 2020-04-16 10:06:55 +01:00 committed by GitHub
parent c2ea961909
commit c1bca95adb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 199 additions and 22 deletions

View file

@ -25,6 +25,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
"github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/dendrite/roomserver/api"
// Import the postgres database driver.
@ -62,7 +63,7 @@ type SyncServerDatasource struct {
func NewSyncServerDatasource(dbDataSourceName string) (*SyncServerDatasource, error) {
var d SyncServerDatasource
var err error
if d.db, err = sql.Open("postgres", dbDataSourceName); err != nil {
if d.db, err = sqlutil.Open("postgres", dbDataSourceName); err != nil {
return nil, err
}
if err = d.PartitionOffsetStatements.Prepare(d.db, "syncapi"); err != nil {

View file

@ -27,6 +27,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
"github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/dendrite/roomserver/api"
// Import the sqlite3 package
@ -78,7 +79,7 @@ func NewSyncServerDatasource(dataSourceName string) (*SyncServerDatasource, erro
} else {
return nil, errors.New("no filename or path in connect string")
}
if d.db, err = sql.Open(common.SQLiteDriverName(), cs); err != nil {
if d.db, err = sqlutil.Open(common.SQLiteDriverName(), cs); err != nil {
return nil, err
}
if err = d.prepare(); err != nil {