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

structured logging: handle unusual keys? #275

Closed
3 tasks
pohly opened this issue Nov 30, 2021 · 9 comments · Fixed by #333
Closed
3 tasks

structured logging: handle unusual keys? #275

pohly opened this issue Nov 30, 2021 · 9 comments · Fixed by #333
Assignees
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging.

Comments

@pohly
Copy link

pohly commented Nov 30, 2021

/kind feature

Describe the solution you'd like

The current design decision is to dump keys as strings without any checks. If those keys contain spaces, line breaks, or other weird characters, then the log output will get messed up.

Presumably this was done for the sake of performance. We should measure the impact of validating keys and substituting unsafe ones. If the overhead is acceptable, we might decide to make the code more robust.

TODO:

  • add test cases with non-string keys (int, bool, struct) to test/output.go with the expected result for the current code, submit PR for discussion
  • decide if and how to enhance the output
  • if we agree on changes, implement those and compare performance of go test -bench=. before and after the changes

Anything else you would like to add:

Brought up in #273 (comment)

/wg structured-logging

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging. labels Nov 30, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 28, 2022
@pohly
Copy link
Author

pohly commented Mar 1, 2022

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 1, 2022
@pohly
Copy link
Author

pohly commented Mar 1, 2022

/help

@k8s-ci-robot
Copy link

@pohly:
This request has been marked as needing help from a contributor.

Guidelines

Please ensure that the issue body includes answers to the following questions:

  • Why are we solving this issue?
  • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
  • Does this issue have zero to low barrier of entry?
  • How can the assignee reach out to you for help?

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/help

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Mar 1, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 30, 2022
@pohly
Copy link
Author

pohly commented May 30, 2022

/remove-lifecycle stale
/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 30, 2022
@harshanarayana
Copy link

/assign

@pohly
Copy link
Author

pohly commented Jun 20, 2022

Not sure where this use comment is now, but it seems relevant, so let me quote and reply:

I was adding a few test cases to the output.go as suggested in the description of this issue and add some additional thing to benchmarking. But zapr has a different way of handling non string keys in
the KVList.: DPanic("non-string key argument passed to logging, ignoring all later arguments", zapIt("invalid key", key)

So it panics instead of continuing with the tests?

Skipping such tests is one way of avoiding this, but ultimately we want to test also such behavior. Perhaps the logger invocation can be wrapped with a defer func() { if r := recover(); r != nil { ... that then records the panic and continues? The panic then needs to be part of the expected log output.

@harshanarayana
Copy link

@pohly I was adding that comment from my phone. Seems like I deleted it by mistake. Thanks for getting back to me.

So it panics instead of continuing with the tests?

No it does not. It causes a log entry with "level":"dpanic" to show up. Part of how the zap handles things in development logger mode.

I started adding a few tests and there are considerable difference in how the zapr handles the log in comparison with klog. Will open a PR with some example tests cases to start the discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants