Repository navigation
Make the log level of Go services configurable - #2413
Merged
Merged
Conversation
All Go services call services.SetupServiceLogging(), which hard coded the logrus level to info. Operators who want to reduce log volume (or debug a service) had no way to change it without rebuilding. Add a common --log_level flag, which can also be set through the PL_LOG_LEVEL environment variable like every other service flag, and use it in SetupServiceLogging(). It accepts any logrus level name (panic, fatal, error, warn, info, debug, trace) and defaults to info, so existing deployments keep their current behavior. An invalid value is a fatal configuration error, in line with how CheckServiceFlags() handles other invalid flags. Fixes pixie-io#2280 Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
vihangm
approved these changes
Oct 26, 2026
Member
|
ASAN test seems to be flaky on main. Merging. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary: Make the log level of Go services configurable
Every Go service in Pixie Cloud and Vizier calls
services.SetupServiceLogging(), which hard coded the logrus level toinfo. As discussed in the issue, there was no way to reduce log volume or turn on debug logging without rebuilding.Following the approach suggested in the issue, this PR adds a common
--log_levelflag toservice_flags.goand uses it inSetupServiceLogging(). Like the other service flags, it can also be set with thePL_LOG_LEVELenvironment variable. It accepts any logrus level (panic,fatal,error,warn,info,debug,trace, case insensitive) and defaults toinfo, so current deployments behave exactly as before. An invalid value is a fatal configuration error, the same wayCheckServiceFlags()handles other invalid flags.The level is applied after flags are parsed, so the
Starting serviceline thatSetupService()logs before parsing is still printed at info level.This only affects the Go logrus logger. The C++ (glog) logging in PEM, Kelvin and the query broker already has its own runtime flags.
Relevant Issues: Fixes #2280
Type of change: /kind feature
Test Plan: Added
//src/shared/services:services_test, which checks the default level, explicit levels, case insensitivity, and that an invalid level is fatal. The explicit level cases fail onmain. I also builtscriptmgrand ran it locally. With no flag it logs at info. With--log_level=error, only error logs are printed after startup. WithPL_LOG_LEVEL=debug, debug logs are printed. With--log_level=bogus, it exits withFlag --log_level or ENV PL_LOG_LEVEL is invalid.go vetand golangci-lint v2.3.1 with the repo's.golangci.yamlare clean.Changelog Message: