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

improve readability of registry debug logs #851

Closed
qweeah opened this issue Mar 2, 2023 · 1 comment · Fixed by #861
Closed

improve readability of registry debug logs #851

qweeah opened this issue Mar 2, 2023 · 1 comment · Fixed by #861
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@qweeah
Copy link
Contributor

qweeah commented Mar 2, 2023

trace package provides http level debug logging for registry-related commands. Since the outgoing requests and incoming response can be processed concurrently, logs in different may intersect between different roundtrip calls.

To make concurrent logs more readable:

  1. Logs for each request/response should be taken atomically. Taking request logging as an example, below logs should be taken in one Logrus call:

e.Debugf("> Request URL: %q", req.URL)
e.Debugf("> Request method: %q", req.Method)
e.Debugf("> Request headers:")
logHeader(req.Header, e)

  1. Add a counter for each request/response so a roundtrip pair can be correlated like below:
Request #1
> URL: "http://localhost:5000/v2/command/images/manifests/multi"
> Method: "GET"
> Headers:
   "Accept": "application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, application/vnd.oci.artifact.manifest.v1+json"
   "User-Agent": "oras/1.0.0-rc.1"

Request #2
> URL: "http://localhost:5000/v2/command/images/manifests/multi"
> Method: "GET"
> Headers:
   "Accept": "application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, application/vnd.oci.artifact.manifest.v1+json"
   "Authorization": "*****"
   "User-Agent": "oras/1.0.0-rc.1"

Response #2
< Status: "200 OK"
< Headers:
   "Content-Length": "706"
   "Content-Type": "application/vnd.oci.image.index.v1+json"
   "Docker-Content-Digest": "sha256:e2bfc9cc6a84ec2d7365b5a28c6bc5806b7fa581c9ad7883be955a64e3cc034f"
   "Docker-Distribution-Api-Version": "registry/2.0"
   "Etag": "\"sha256:e2bfc9cc6a84ec2d7365b5a28c6bc5806b7fa581c9ad7883be955a64e3cc034f\""
   "X-Content-Type-Options": "nosniff"
   "Date": "Thu, 02 Mar 2023 15:14:31 GMT"

Response #1
< Status: "401 Unauthorized"
< Headers:
   "Content-Type": "application/json"
   "Docker-Distribution-Api-Version": "registry/2.0"
   "Www-Authenticate": "Basic realm=\"test-basic\""
   "X-Content-Type-Options": "nosniff"
   "Date": "Thu, 02 Mar 2023 15:14:31 GMT"
   "Content-Length": "157"
...
@qweeah qweeah added the enhancement New feature or request label Mar 2, 2023
@qweeah qweeah added this to the v1.0.0 milestone Mar 2, 2023
@wangxiaoxuan273
Copy link
Contributor

I would like to work on this item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants