forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Serve] integrate with Ray structured logging (ray-project#46215)
<!-- Thank you for your contribution! Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request. --> <!-- Please add a reviewer to the assignee section when you create a PR. If you don't have the access to it, we will shortly find a reviewer and assign them to your PR. --> ## Why are these changes needed? Integrated Ray structured logging into Serve's logger. Two things are done in this PR: 1. Moved the logics to flatten serve's special key for extra logging attributes to `_append_flatten_attributes()` and called it from `generate_record_format_attrs()` so Ray structured logging can apply those nested attributes 2. Refactored Serve's json formatter into context filters and applied them onto Serve's log handlers. Reuses core's `JSONFormatter` when formatting structured logs The main difference after integrated with Ray structured logging is there are new attributes provided by Ray (e.g. `node_id`, `filename`, and `lineno`). Also, the message format is just the message body itself, without filename and line number prefix. Example log before the change ``` { "levelname":"INFO", "asctime":"2024-06-24 22:15:34,526", "actor_id":"59ef544fa6127fffd1b6c4ad01000000", "worker_id":"ce0efd00c47b08f51a5c04e2cdfb8919ed6df4d0b4b938d3e75b4321", "deployment":"app_Counter", "replica":"j8fhh1bm", "component_name":"replica", "request_id":"6f04a2fd-db85-4687-8302-ef478e7abee8", "route":"/favicon.ico", "application":"app", "message":"replica.py:373 - __CALL__ OK 2.8ms" } ``` Example log after the change ``` { "asctime":"2024-06-24 22:10:57,906", "levelname":"INFO", "message":"__CALL__ OK 4.3ms", "filename":"replica.py", "lineno":373, "worker_id":"833490a0fcc662b86c04403694c85b1d14364a05b5c6d6dfec5d5d47", "node_id":"1f3b2424bccc7f407fad2bf549954b723ea46405dded64d7386239a7", "actor_id":"b5f78e9af7148f019d9e89ab01000000", "route":"/favicon.ico", "request_id":"59f62350-7da6-47a2-a964-b6dd4e512003", "application":"app", "deployment":"app_Counter", "replica":"8p7guoov", "component_name":"replica" } ``` ## Related issue number Closes ray-project#46125 ## Checks - [ ] I've signed off every commit(by using the -s flag, i.e., `git commit -s`) in this PR. - [ ] I've run `scripts/format.sh` to lint the changes in this PR. - [ ] I've included any doc changes needed for https://docs.ray.io/en/master/. - [ ] I've added any new APIs to the API Reference. For example, if I added a method in Tune, I've added it in `doc/source/tune/api/` under the corresponding `.rst` file. - [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ - Testing Strategy - [ ] Unit tests - [ ] Release tests - [ ] This PR is not tested :( --------- Signed-off-by: Gene Su <e870252314@gmail.com> Signed-off-by: Gene Der Su <gdsu@ucdavis.edu> Co-authored-by: Jiajun Yao <jeromeyjj@gmail.com>
- Loading branch information
Showing
6 changed files
with
181 additions
and
136 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.