-
Notifications
You must be signed in to change notification settings - Fork 928
chore: populate connectionlog count using a separate query #18629
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
base: ethan/connection-logs-api
Are you sure you want to change the base?
chore: populate connectionlog count using a separate query #18629
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
ed8e139
to
8cec6d1
Compare
a031154
to
d03fe73
Compare
8cec6d1
to
482a5d3
Compare
d03fe73
to
8cbd44a
Compare
482a5d3
to
ccc7539
Compare
8cbd44a
to
09cbe49
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a separate count query for connection logs so that the ConnectionLogResponse
includes a total count, mitigating performance issues described in #17689. Key changes include:
- HTTP handler now runs
CountConnectionLogs
and populatesCount
in its response. searchquery.ConnectionLogs
returns two filter structs (offsetFilter
andcountFilter
) and the handler invokes the newCountConnectionLogs
method.- Added SQL and Go plumbing (queries, querier interfaces, mocks, metrics, in-memory impl, authorization, and tests) to support counting connection logs.
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
enterprise/coderd/connectionlog.go | Calls CountConnectionLogs before fetching paged results and writes Count in the response |
enterprise/coderd/connectionlog_test.go | Adds assertions for the new Count field in tests |
coderd/searchquery/search.go | Updated ConnectionLogs to return a CountConnectionLogsParams filter |
coderd/searchquery/search_test.go | Adjusted tests to unpack the new return value |
coderd/database/queries/connectionlogs.sql | Introduced CountConnectionLogs SQL query |
coderd/database/queries.sql.go | Added countConnectionLogs constant and CountConnectionLogs implementation |
coderd/database/querier.go | Extended querier interface with CountConnectionLogs |
coderd/database/modelqueries_internal_test.go | Added consistency test to ensure both queries share the same WHERE clause |
coderd/database/modelqueries.go | Implemented CountAuthorizedConnectionLogs |
coderd/database/dbmock/dbmock.go | Generated mocks for the new count methods |
coderd/database/dbmetrics/querymetrics.go | Wrapped new count methods with latency metrics |
coderd/database/dbmem/dbmem.go | Added in-memory implementation of CountConnectionLogs |
coderd/database/dbauthz/setup_test.go | Unified empty-response checks for count tests |
coderd/database/dbauthz/dbauthz_test.go | Added RBAC tests for count methods |
coderd/database/dbauthz/dbauthz.go | Authorized count methods in the dbauthz layer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - similar to my PR #18600
ccc7539
to
406e3f4
Compare
09cbe49
to
0f13056
Compare
This is the third PR for moving connection events out of the audit log.
This PR populates
count
onConnectionLogResponse
using a separate query, to preemptively mitigate the issue described in #17689. It's structurally identical to a portion of #18600, but for the connection log instead of the audit log.Future PRs: