-
Notifications
You must be signed in to change notification settings - Fork 249
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
Ability to change log verbosity while the node is running #799
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #799 +/- ##
==========================================
- Coverage 62.53% 62.18% -0.36%
==========================================
Files 203 204 +1
Lines 18731 18840 +109
==========================================
+ Hits 11713 11715 +2
- Misses 5920 6027 +107
Partials 1098 1098 ☔ View full report in Codecov by Sentry. |
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.
Looks good - ooc is there a way that we can test this feature on unit tests ?
Co-authored-by: Darren Kelly <[email protected]>
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.
Overall lgtm, I am starting to think that it can be benefitial to follow the same API struct pattern as the api package and perhaps having a couple of kickstarter unit tests ?
func HTTPHandler(logLevel *slog.LevelVar) http.Handler { | ||
router := mux.NewRouter() | ||
router.HandleFunc("/admin/loglevel", logLevelHandler(logLevel)) | ||
return handlers.CompressHandler(router) | ||
} |
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.
What if the same pattern of the api package was used ?
Maybe something like:
admin/api.go - similar to api/api.go
The struct that handles start and stop of the server and mounts the endpoints.
admin/log.go - similar to accounts/accounts.go
The struct that has handlers for the log level changes and mounts into a subrouter
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.
Wouldn't it make more sense to use the same pattern as the metrics server since our goal is something similar? In the metric's case the startMetricsServer
is in the utils.go
file while the handler is returned from the telemetry.go
file similar to my admin.go
file. If not are you suggesting I move startMetricsServer
into its own file basically?
@@ -587,6 +592,27 @@ func startMetricsServer(addr string) (string, func(), error) { | |||
}, nil | |||
} | |||
|
|||
func startAdminServer(addr string, logLevel *slog.LevelVar) (string, func(), error) { |
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.
Should this live in the admin
package. And starting the admin server would follow the same patter as the api package?
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.
Not sure. For this I just used the same pattern that is used in metrics with startMetricsServer
living in utils.go
.
// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying | ||
// file LICENSE or <https://www.gnu.org/licenses/lgpl-3.0.html> | ||
|
||
package admin |
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.
Do you think it would be good to have some unit tests ? Since we're setting the package up, perhaps it would make any refactor easy at this stage.
This PR adds a new server running on a separate port (default 2113) bound to localhost and disabled by default. It implements a route
/admin
and uses query parameters to get the new verbosity level. To use it you can run thor with the following arguments:and use the following curl command to change the verbosity
curl "http://localhost:2113/admin?verbosity=debug"
The available options are
debug
,info
,warn
,error
,trace
,crit