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(log): log http requests for OCI and docker based on trace level by injecting a logger #1118

Conversation

jakobmoellerdev
Copy link
Contributor

@jakobmoellerdev jakobmoellerdev commented Nov 20, 2024

What this PR does / why we need it

it is now possible to inject a trace attribute to OCMs logging architecture to allow tracing back HTTP calls for oci registries and the docker client:

ocm --logkeys /+ocm/oci=trace [YOUR COMMAND INTERACTING WITH OCI HERE]

Note that this does not take care of all access types yet because we dont have a unified http.Client.

Note that it is now also possible to pass /+ocm/docker=trace to enable logging for the docker client infrastructure, or set --loglevel=trace to get a full tracelog with HTTP statements.

Authorization Headers are redacted

Which issue(s) this PR fixes

This allows introspecting HTTP calls for debugging purposes, e.g.

bin/ocm --logkeys /+ocm/oci=trace transfer artifact CommonTransportFormat::XXX/ocm/gen/ctf//component-descriptors/ocm.software/ocmcli ghcr.io/jakobmoellerdev/ocm:latest
copying CommonTransportFormat::XXX/ocm/gen/ctf//component-descriptors/ocm.software/ocmcli:0.17.0-dev to ghcr.io/jakobmoellerdev/ocm:latest...
 2024-11-20T19:09:14+01:00 trace   [ocm/oci/ocireg] roundtrip header="{\"Accept\":[\"application/vnd.ocm.software.component.config.v1+json, */*\"],\"User-Agent\":[\"containerd/1.7.23+unknown\"]}" host=ghcr.io method=HEAD namespace=jakobmoellerdev/ocm url=https://ghcr.io/v2/jakobmoellerdev/ocm/blobs/sha256:0351859d79ce5900e610226ed03ab0fb5586f4f19b26693487bf13fac1ce6923
 2024-11-20T19:09:14+01:00 trace   [ocm/oci/ocireg] "query credentials" host=ghcr.io namespace=jakobmoellerdev/ocm pass="***" user=jakobmoellerdev

@jakobmoellerdev jakobmoellerdev requested a review from a team as a code owner November 20, 2024 18:07
@github-actions github-actions bot added the size/m Medium label Nov 20, 2024
@jakobmoellerdev jakobmoellerdev added the kind/feature new feature, enhancement, improvement, extension label Nov 20, 2024
@jakobmoellerdev jakobmoellerdev force-pushed the feat/logging-http-roundtripper branch from 3afa48c to ff50045 Compare November 20, 2024 18:13
@jakobmoellerdev jakobmoellerdev force-pushed the feat/logging-http-roundtripper branch from ff50045 to 33d674c Compare November 20, 2024 19:18
api/oci/extensions/repositories/docker/logging.go Outdated Show resolved Hide resolved
api/oci/extensions/repositories/ocireg/repository.go Outdated Show resolved Hide resolved
api/utils/logging/roundtripper.go Show resolved Hide resolved
api/utils/logging/roundtripper.go Show resolved Hide resolved
@jakobmoellerdev jakobmoellerdev force-pushed the feat/logging-http-roundtripper branch 2 times, most recently from 36f585f to e26b479 Compare November 21, 2024 08:56
it is now possible to inject a trace attribute to OCMs logging architecture to allow tracing back HTTP calls for oci registries and the docker client:

```
ocm --logkeys /+ocm/oci=trace [YOUR COMMAND INTERACTING WITH OCI HERE]
```

Note that this does not take care of all access types yet because we dont have a unified http.Client
@jakobmoellerdev jakobmoellerdev force-pushed the feat/logging-http-roundtripper branch from e26b479 to 932252d Compare November 21, 2024 09:00
Copy link
Contributor

@fabianburth fabianburth left a comment

Choose a reason for hiding this comment

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

Looks good

@jakobmoellerdev jakobmoellerdev merged commit 10f26eb into open-component-model:main Nov 21, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature new feature, enhancement, improvement, extension size/m Medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants