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

Core: set the zap time encoder to include nanos #731

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

benashz
Copy link
Collaborator

@benashz benashz commented May 8, 2024

Updates the zap logger to include timestamps with nano second resolution.

E.g:

2024-05-08T14:02:26.489440746Z  INFO    Stopping and waiting for caches
2024-05-08T14:02:26.489861624Z  INFO    Stopping and waiting for webhooks
2024-05-08T14:02:26.489883565Z  INFO    Stopping and waiting for HTTP servers

@benashz benashz requested a review from a team as a code owner May 8, 2024 14:58
@benashz benashz requested review from tvoran and thyton May 8, 2024 16:50
@@ -118,6 +119,7 @@ func main() {
"Valid values are: %v", []string{"exclude-raw"}))
opts := zap.Options{
Development: true,
TimeEncoder: zapcore.RFC3339NanoTimeEncoder,
Copy link
Member

Choose a reason for hiding this comment

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

Curious why this needs to be nanosecond precision? I see that Vault itself seems to go down to millisecond for its logs (e.g. 2024-05-09T16:28:09.271Z).

Would it make sense for this to be a development or debug mode option?

Copy link
Collaborator Author

@benashz benashz May 9, 2024

Choose a reason for hiding this comment

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

Curious why this needs to be nanosecond precision? I see that Vault itself seems to go down to millisecond for its logs (e.g. 2024-05-09T16:28:09.271Z).

I think this follows the timestamp format of the K8s control plane using https://cs.opensource.google/go/go/+/refs/tags/go1.22.3:src/time/format.go;l=112.

e.g:

2024-05-08T15:00:34.614182314Z stderr F 2024-05-08T15:00:34Z    INFO    Starting EventSource    {"controller": "vaultstaticsecret", "controllerGroup": "secrets.hashicorp.com", "controllerKind": "VaultStaticSecret", "source": "kind source: unknown type"}

Could go to millis. Not sure.

Would it make sense for this to be a development or debug mode option?

Perhaps. I always prefer a higher resolution by default.

@benashz benashz added this to the v0.8.0 milestone May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants