Skip to content

Use structured logging #330

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

Merged
merged 2 commits into from
Feb 13, 2025
Merged

Conversation

tchap
Copy link
Contributor

@tchap tchap commented Feb 13, 2025

All logging calls are rewritten to use structured logging.

I did go run k8s.io/klog/hack/tools/logcheck -check-structured ./... and fixed all issues detected.

Related to #251

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 13, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @tchap. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 13, 2025
Copy link

netlify bot commented Feb 13, 2025

Deploy Preview for gateway-api-inference-extension ready!

Name Link
🔨 Latest commit 68a1e20
🔍 Latest deploy log https://app.netlify.com/sites/gateway-api-inference-extension/deploys/67ae58909f3a4400088d36de
😎 Deploy Preview https://deploy-preview-330--gateway-api-inference-extension.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@tchap tchap force-pushed the structured-logging branch 3 times, most recently from be2fca6 to dfab5ce Compare February 13, 2025 15:55
@@ -16,7 +17,7 @@ func (f *FakePodMetricsClient) FetchMetrics(ctx context.Context, pod Pod, existi
if err, ok := f.Err[pod]; ok {
return nil, err
}
klog.V(1).Infof("pod: %+v\n existing: %+v \n new: %+v \n", pod, existing, f.Res[pod])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems like a VERBOSE message to me, but not sure.

@@ -101,7 +102,7 @@ func (s *Server) HandleRequestBody(reqCtx *RequestContext, req *extProcPb.Proces
}
// Print headers for debugging
for _, header := range headers {
klog.V(logutil.VERBOSE).Infof("[request_body] Header Key: %s, Header Value: %s\n", header.Header.Key, header.Header.RawValue)
klog.V(logutil.DEBUG).InfoS("Request body header", "key", header.Header.Key, "value", header.Header.RawValue)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like DEBUG level to me.

@ahg-g
Copy link
Contributor

ahg-g commented Feb 13, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 13, 2025
@tchap tchap force-pushed the structured-logging branch from dfab5ce to 1074d01 Compare February 13, 2025 16:05
@@ -16,10 +17,10 @@ type healthServer struct {

func (s *healthServer) Check(ctx context.Context, in *healthPb.HealthCheckRequest) (*healthPb.HealthCheckResponse, error) {
if !s.datastore.HasSynced() {
klog.Infof("gRPC health check not serving: %s", in.String())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems like at least VERBOSE logging to me.

@tchap tchap force-pushed the structured-logging branch 2 times, most recently from 9a94693 to 9de3439 Compare February 13, 2025 19:22
All logging calls are rewritten to use structured logging.
@tchap tchap force-pushed the structured-logging branch from 9de3439 to c79e378 Compare February 13, 2025 19:24
@@ -26,19 +26,21 @@ func (c *InferenceModelReconciler) Reconcile(ctx context.Context, req ctrl.Reque
if req.Namespace != c.PoolNamespacedName.Namespace {
return ctrl.Result{}, nil
}
klog.V(1).Infof("Reconciling InferenceModel %v", req.NamespacedName)

klogV := klog.V(logutil.DEFAULT)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this pattern, but what happens when I want to use a non-default log level, mixing the logging objects might be odd. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, you can always just do klog.V with another level when needed. I think that there is a function somewhere here that actually uses klogV for VERBOSE and klog.V(logutil.DEFAULT) is done explicitly. There is no rule really, just saving some typing.

Actually doing klogDEBUG := klog.V(logutil.DEBUG) would be more readable as klogV does not always point to the same verbose level, but I don't have a strong feeling about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that I will reconsider this when implementing contextual logging, don't feel like postponing this.

@kfswain
Copy link
Collaborator

kfswain commented Feb 13, 2025

overall lgtm! Just one real comment, and the decision to change some of the logging levels is totally fine to me.

Thanks! This looks great

@kfswain
Copy link
Collaborator

kfswain commented Feb 13, 2025

/lgtm
/hold

Feel free to unhold at your discretion

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 13, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 13, 2025
@tchap
Copy link
Contributor Author

tchap commented Feb 13, 2025

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 13, 2025
@tchap
Copy link
Contributor Author

tchap commented Feb 13, 2025

Can someone approve this for me pls? The last thing missing 🙂

@ahg-g
Copy link
Contributor

ahg-g commented Feb 13, 2025

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahg-g, tchap

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 13, 2025
@k8s-ci-robot k8s-ci-robot merged commit ef9b92f into kubernetes-sigs:main Feb 13, 2025
7 of 8 checks passed
@tchap tchap deleted the structured-logging branch February 13, 2025 23:54
kfswain pushed a commit to kfswain/llm-instance-gateway that referenced this pull request Apr 29, 2025
* Use structured logging

All logging calls are rewritten to use structured logging.

* test/integration: Use logutil.Fatal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants