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

feat: Improve GitHub and GitLab Debug Logging #3876

Merged
merged 6 commits into from
Oct 20, 2023

Conversation

X-Guardian
Copy link
Contributor

@X-Guardian X-Guardian commented Oct 19, 2023

what

Improve the GitHub and GitLab client debug logging so that each API call is logged along with the HTTP status response.

The GitLab Client tests also needed updating with a logger property on the Gitlab Client.

why

To help with debugging VCS issues in the future.

Example Logs

GitHub

{"level":"debug","ts":"2023-10-19T20:17:16.087+0100","caller":"vcs/github_client.go:104","msg":"GH User: X-Guardian","json":{}}
{"level":"debug","ts":"2023-10-19T20:17:42.631+0100","caller":"vcs/github_client.go:204","msg":"POST /repos/Guardian-Teck/atlantis-test/issues/comments/1771570849/reactions returned: 201","json":{}}
{"level":"debug","ts":"2023-10-19T20:17:42.929+0100","caller":"vcs/github_client.go:554","msg":"GET /repos/Guardian-Teck/atlantis-test/pulls/6 returned: 200","json":{}}
{"level":"debug","ts":"2023-10-19T20:17:43.186+0100","caller":"vcs/github_client.go:331","msg":"GET /repos/Guardian-Teck/atlantis-test/pulls/6/reviews returned: 200","json":{}}
{"level":"debug","ts":"2023-10-19T20:17:43.539+0100","caller":"vcs/github_client.go:554","msg":"GET /repos/Guardian-Teck/atlantis-test/pulls/6 returned: 200","json":{}}
{"level":"debug","ts":"2023-10-19T20:17:43.846+0100","caller":"vcs/github_client.go:586","msg":"POST /repos/Guardian-Teck/atlantis-test/statuses/92ec829ba24d094f96a9c5bb038590abab3c3e98 returned: 201","json":{}}
{"level":"debug","ts":"2023-10-19T20:17:44.246+0100","caller":"vcs/github_client.go:144","msg":"[attempt 1] GET /repos/Guardian-Teck/atlantis-test/pulls/6/files returned: 200","json":{}}
{"level":"debug","ts":"2023-10-19T20:17:44.754+0100","caller":"vcs/github_client.go:586","msg":"POST /repos/Guardian-Teck/atlantis-test/statuses/92ec829ba24d094f96a9c5bb038590abab3c3e98 returned: 201","json":{}}
{"level":"debug","ts":"2023-10-19T20:17:47.096+0100","caller":"vcs/github_client.go:586","msg":"POST /repos/Guardian-Teck/atlantis-test/statuses/92ec829ba24d094f96a9c5bb038590abab3c3e98 returned: 201","json":{}}
{"level":"debug","ts":"2023-10-19T20:17:47.525+0100","caller":"vcs/github_client.go:217","msg":"GET /repos/Guardian-Teck/atlantis-test/issues/6/comments returned: 200","json":{}}

GitLab

{"level":"debug","ts":"2023-10-19T20:09:05.527+0100","caller":"vcs/gitlab_client.go:463","msg":"GET /version returned: 200","json":{}}
{"level":"debug","ts":"2023-10-19T20:09:18.177+0100","caller":"vcs/gitlab_client.go:193","msg":"POST /projects/sheather/test/merge_requests/15/notes/389/award_emoji returned: 201","json":{}}
{"level":"debug","ts":"2023-10-19T20:09:19.410+0100","caller":"vcs/gitlab_client.go:393","msg":"GET /projects/sheather/test/merge_requests/15 returned: 200","json":{}}
{"level":"debug","ts":"2023-10-19T20:09:20.229+0100","caller":"vcs/gitlab_client.go:393","msg":"GET /projects/sheather/test/merge_requests/15 returned: 200","json":{}}
{"level":"debug","ts":"2023-10-19T20:09:20.449+0100","caller":"vcs/gitlab_client.go:387","msg":"POST /projects/sheather/test/statuses/2b55ac78b1c87c208bd87723293c752a2e619470 returned: 201","json":{}}
{"level":"debug","ts":"2023-10-19T20:09:50.684+0100","caller":"vcs/gitlab_client.go:393","msg":"GET /projects/sheather/test/merge_requests/15 returned: 200","json":{}}
{"level":"debug","ts":"2023-10-19T20:09:50.946+0100","caller":"vcs/gitlab_client.go:387","msg":"POST /projects/sheather/test/statuses/2b55ac78b1c87c208bd87723293c752a2e619470 returned: 201","json":{}}
{"level":"debug","ts":"2023-10-19T20:09:51.326+0100","caller":"vcs/gitlab_client.go:261","msg":"GET /projects/sheather/test/merge_requests/15/approvals returned: 200","json":{}}
{"level":"debug","ts":"2023-10-19T20:09:52.173+0100","caller":"vcs/gitlab_client.go:286","msg":"GET /projects/sheather/test/merge_requests/15 returned: 200","json":{}}
{"level":"debug","ts":"2023-10-19T20:09:52.311+0100","caller":"vcs/gitlab_client.go:302","msg":"GET /projects/2 returned: 200","json":{}}
{"level":"debug","ts":"2023-10-19T20:09:52.480+0100","caller":"vcs/gitlab_client.go:309","msg":"GET /projects/2/commits/2b55ac78b1c87c208bd87723293c752a2e619470/statuses returned: 200","json":{}}
{"level":"debug","ts":"2023-10-19T20:09:52.557+0100","caller":"vcs/gitlab_client.go:463","msg":"GET /version returned: 200","json":{}}
{"level":"debug","ts":"2023-10-19T20:09:52.891+0100","caller":"vcs/gitlab_client.go:393","msg":"GET /projects/sheather/test/merge_requests/15 returned: 200","json":{}}
{"level":"debug","ts":"2023-10-19T20:09:53.193+0100","caller":"vcs/gitlab_client.go:387","msg":"POST /projects/sheather/test/statuses/2b55ac78b1c87c208bd87723293c752a2e619470 returned: 201","json":{}}

@X-Guardian X-Guardian requested a review from a team as a code owner October 19, 2023 19:20
@github-actions github-actions bot added go Pull requests that update Go code provider/github provider/gitlab labels Oct 19, 2023
Copy link
Contributor

@jamengual jamengual left a comment

Choose a reason for hiding this comment

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

LGTM thanks @X-Guardian

@jamengual jamengual merged commit edc9bd9 into runatlantis:main Oct 20, 2023
13 checks passed
GenPage pushed a commit that referenced this pull request Nov 14, 2023
* Improve GitHub and GitLab Debug Logging

* Fix formatting

* Fix g.client.Repositories.Get debug message

* Update gitlab_client_test with logger

---------

Co-authored-by: PePe Amengual <[email protected]>
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* Improve GitHub and GitLab Debug Logging

* Fix formatting

* Fix g.client.Repositories.Get debug message

* Update gitlab_client_test with logger

---------

Co-authored-by: PePe Amengual <[email protected]>
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
* Improve GitHub and GitLab Debug Logging

* Fix formatting

* Fix g.client.Repositories.Get debug message

* Update gitlab_client_test with logger

---------

Co-authored-by: PePe Amengual <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code provider/github provider/gitlab
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants