Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Add SQL tracing via DENDRITE_TRACE_SQL #968

Merged
merged 3 commits into from
Apr 16, 2020
Merged

Add SQL tracing via DENDRITE_TRACE_SQL #968

merged 3 commits into from
Apr 16, 2020

Conversation

kegsay
Copy link
Member

@kegsay kegsay commented Apr 15, 2020

Add this to internal/sqlutil in preparation for #897

Produces output like:

time="2020-04-15T17:02:43.962987300Z" level=debug msg="executed sql query SELECT event_type_nid, event_state_key_nid, event_nid FROM roomserver_events WHERE event_id = ANY($1) ORDER BY event_type_nid, event_state_key_nid ASC args: [{ 1 {\"$j2EMXU2F627tJC9W:localhost:8800\",\"$lrow6qtck9gCRc7J:localhost:8800\",\"$PeHnafX7TRLcqHsJ:localhost:8800\"}}]" func="github.com/matrix-org/dendrite/internal/sqlutil.(*traceInterceptor).StmtQueryContext" file="/src/internal/sqlutil/trace.go:40" duration="376.5µs" error="<nil>"
time="2020-04-15T17:02:43.963101100Z" level=debug msg="event_type_nid | event_state_key_nid | event_nid" func="github.com/matrix-org/dendrite/internal/sqlutil.(*traceInterceptor).RowsNext" file="/src/internal/sqlutil/trace.go:62"
time="2020-04-15T17:02:43.963137000Z" level=debug msg="1 | 1 | 161" func="github.com/matrix-org/dendrite/internal/sqlutil.(*traceInterceptor).RowsNext" file="/src/internal/sqlutil/trace.go:71"
time="2020-04-15T17:02:43.963177500Z" level=debug msg="event_type_nid | event_state_key_nid | event_nid" func="github.com/matrix-org/dendrite/internal/sqlutil.(*traceInterceptor).RowsNext" file="/src/internal/sqlutil/trace.go:62"
time="2020-04-15T17:02:43.963284300Z" level=debug msg="2 | 1 | 163" func="github.com/matrix-org/dendrite/internal/sqlutil.(*traceInterceptor).RowsNext" file="/src/internal/sqlutil/trace.go:71"
time="2020-04-15T17:02:43.963322800Z" level=debug msg="event_type_nid | event_state_key_nid | event_nid" func="github.com/matrix-org/dendrite/internal/sqlutil.(*traceInterceptor).RowsNext" file="/src/internal/sqlutil/trace.go:62"
time="2020-04-15T17:02:43.963356800Z" level=debug msg="3 | 1 | 164" func="github.com/matrix-org/dendrite/internal/sqlutil.(*traceInterceptor).RowsNext" file="/src/internal/sqlutil/trace.go:71"

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

@neilalexander neilalexander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK to me, bar removing a line.

@@ -39,7 +41,8 @@ type Database struct {
func Open(dataSourceName string) (*Database, error) {
var d Database
var err error
if d.db, err = sql.Open("postgres", dataSourceName); err != nil {
logrus.WithField("yep", "no").Info("NOT ENTIRELY CRAZY")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably doesn't want to be in the final merge :D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, noooo my secret logging lines!

@kegsay kegsay merged commit c1bca95 into master Apr 16, 2020
@kegsay kegsay deleted the kegan/trace-sql branch April 16, 2020 09:06
neilalexander added a commit that referenced this pull request Apr 16, 2020
commit c1bca95
Author: Kegsay <[email protected]>
Date:   Thu Apr 16 10:06:55 2020 +0100

    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

commit c2ea961
Author: Kegsay <[email protected]>
Date:   Wed Apr 15 17:48:40 2020 +0100

    Add HTTP trace logging (#965)

    * Dump all requests/response server-side

    * Wrap in DENDRITE_TRACE

    * DENDRITE_TRACE_HTTP is better

    * Bugfix for response body and linting

    * False is true and true is false

    * Linting

    * How did this get missed

    * More linting
neilalexander added a commit that referenced this pull request Apr 16, 2020
* Set default room version to 4

* Default to v1 when room_version key missing

Signed-off-by: Alex Chen <[email protected]>

* Squashed commit of the following:

commit c1bca95
Author: Kegsay <[email protected]>
Date:   Thu Apr 16 10:06:55 2020 +0100

    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

commit c2ea961
Author: Kegsay <[email protected]>
Date:   Wed Apr 15 17:48:40 2020 +0100

    Add HTTP trace logging (#965)

    * Dump all requests/response server-side

    * Wrap in DENDRITE_TRACE

    * DENDRITE_TRACE_HTTP is better

    * Bugfix for response body and linting

    * False is true and true is false

    * Linting

    * How did this get missed

    * More linting

* Update gomatrixserverlib

* Remove unneeded imports

Co-authored-by: Cnly <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants