Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly measure duration of Query #1042

Merged
merged 3 commits into from
Dec 14, 2020
Merged

Conversation

arielshaqed
Copy link
Contributor

@arielshaqed arielshaqed commented Dec 10, 2020

Measure all the way through reading Rows.


This change is Reviewable

Measure all the way through reading Rows.
@arielshaqed arielshaqed requested a review from nopcoder December 10, 2020 15:20
@arielshaqed
Copy link
Contributor Author

Sample log line:

INFO   [2020-12-10T17:18:36+02:00]db/traced_rows.go:34 db.(*LoggedRows).logDuration rows done                                     args="[foo ]" duration=2.234833ms query="\n\t    WITH resolved_policies_view AS (\n                SELECT auth_policies.id, auth_policies.created_at, auth_policies.display_name, auth_policies.statement, auth_users.display_name AS user_display_name\n                FROM auth_policies INNER JOIN\n                     auth_user_policies ON (auth_policies.id = auth_user_policies.policy_id) INNER JOIN\n\t\t     auth_users ON (auth_users.id = auth_user_policies.user_id)\n                UNION\n\t\tSELECT auth_policies.id, auth_policies.created_at, auth_policies.display_name, auth_policies.statement, auth_users.display_name AS user_display_name\n\t\tFROM auth_policies INNER JOIN\n\t\t     auth_group_policies ON (auth_policies.id = auth_group_policies.policy_id) INNER JOIN\n\t\t     auth_groups ON (auth_groups.id = auth_group_policies.group_id) INNER JOIN\n\t\t     auth_user_groups ON (auth_user_groups.group_id = auth_groups.id) INNER JOIN\n\t\t     auth_users ON (auth_users.id = auth_user_groups.user_id)\n\t    ) SELECT id, created_at, display_name, statement FROM resolved_policies_view WHERE user_display_name = $1 AND display_name > $2 ORDER BY display_name" type="start query"

@arielshaqed arielshaqed added the pr/merge-if-approved Reviewer: please feel free to merge if no major comments label Dec 10, 2020
Copy link
Contributor

@nopcoder nopcoder left a comment

Choose a reason for hiding this comment

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

very cool

@@ -0,0 +1,74 @@
package db
Copy link
Contributor

Choose a reason for hiding this comment

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

align the filename with the type LoggedRows <-> traced_rows

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

l logging.Logger
}

var compileCheck pgx.Rows = &LoggedRows{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
var compileCheck pgx.Rows = &LoggedRows{}
var _ pgx.Rows = &LoggedRows{}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor Author

@arielshaqed arielshaqed left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -0,0 +1,74 @@
package db
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

l logging.Logger
}

var compileCheck pgx.Rows = &LoggedRows{}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@arielshaqed arielshaqed force-pushed the bugfix/observe-sql-query branch from ece82e2 to f9772ea Compare December 13, 2020 16:38
Copy link
Contributor

@nopcoder nopcoder left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 4 files at r1.
Reviewable status: 1 of 4 files reviewed, 2 unresolved discussions (waiting on @nopcoder)

@nopcoder nopcoder merged commit c6ff255 into master Dec 14, 2020
@nopcoder nopcoder deleted the bugfix/observe-sql-query branch December 14, 2020 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/merge-if-approved Reviewer: please feel free to merge if no major comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants