-
Notifications
You must be signed in to change notification settings - Fork 222
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: replace logrus with zap #1020
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1020 +/- ##
==========================================
- Coverage 81.31% 81.26% -0.05%
==========================================
Files 17 17
Lines 1798 1799 +1
==========================================
Hits 1462 1462
- Misses 262 263 +1
Partials 74 74
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Cheers @markphelps, I adjusted those log lines and introduced a
Technically, if byte for byte encoding match with logrus was required, a |
Also, just for context, I also tried out installing zap as the internal gRPC logger implementation. It works: However, it does bring a lot more chatter into the logs.
We could make setting this configurable. I remember that there was a common gRPC environment variable for enabling logs. We could piggyback on that. I also tried out passing the option to adjust log-level based on gRPC response codes.
However, it appears that today Flipt treats gRPC responses as |
Yeah I agree that we should change:
But perhaps in the next release, potentially when we also add the JSON log output option? It makes sense to me that OK responses would be logged as DEBUG instead of INFO (as they are today). I also agree that the change:
Should perhaps piggyback off the env var used by gRPC, (I remember it having a weird name?). Idk how much extra value it would be to add another config for Flipt to control this value, it seems to me that using the decided upon env var by the gRPC community would be good enough? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing! Thank you @GeorgeMac for doing this, it was much needed IMO
🎉 Awesome. Cheers @markphelps We can do it all again in the next 6 months when the dust settles here golang/go#54763 😂 |
Closes: #964
Supports: #992 (with a little work to add supporting config)
This swaps out logrus for zap. I thought I could whip this up quickly for a comparison to aid the discussion.
Zap supports a lot of different configuration.
In fact, the config itself is JSON serializable and could be added to Flipt's own config.
https://pkg.go.dev/go.uber.org/zap#Config
However, for now, I decided to copy and adjust the default “development” config to best match Flips current flag configuration.
I went through a number of call-sites and adjusted the logging to match zap conventions.
I have favoured using zap fields and non-sugared logger.
Which, will make the output more favourable to structured encoding (like JSON).
Furthermore, it should reduce the logging overhead as it removes a bunch of string interpolation.
Before:
After: