-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[Serve] add RAY_SERVE_LOG_ENCODING
env to set the global logging behavior for Serve
#42781
[Serve] add RAY_SERVE_LOG_ENCODING
env to set the global logging behavior for Serve
#42781
Conversation
Signed-off-by: Gene Su <e870252314@gmail.com>
…r for Serve Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
RAY_SERVE_LOG_ENCODING_ENV
env to set the global logging behavior for Serve
Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
["FOOBAR", "TEXT"], | ||
], | ||
) | ||
def test_configure_component_logger_with_log_encoding_env(monkeypatch, log_encoding): |
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.
please also test the override behavior if users specify the encoding in their logging_config
. I assume that env var is lowest precedence
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.
Makes sense, but this kinda requires us to default to an encoding that's neither text nor json in the logging_config
so we know if user has explicitly set it. Let me take a stab
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.
Right now just use None
to represent the encoding not being set in the logging config. But open to adding new enum of NOT_SET
or other ideas :)
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.
Ouch, this actually won't work. The protobuf doesn't like None
😅 Gonna just add a NOT_SET
enum
Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
Signed-off-by: Gene Su <e870252314@gmail.com>
RAY_SERVE_LOG_ENCODING_ENV
env to set the global logging behavior for ServeRAY_SERVE_LOG_ENCODING
env to set the global logging behavior for Serve
# Jsonify the log messages | ||
RAY_SERVE_ENABLE_JSON_LOGGING = os.environ.get("RAY_SERVE_ENABLE_JSON_LOGGING") == "1" |
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.
note here that this one is deprecated and getting removed
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.
Just small comments
python/ray/serve/schema.py
Outdated
@@ -130,10 +135,11 @@ class Config: | |||
extra = Extra.forbid | |||
|
|||
encoding: Union[str, EncodingType] = Field( | |||
default="TEXT", | |||
default_factory=_ray_serve_log_encoding, |
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.
default_factory=_ray_serve_log_encoding, | |
default_factory=lambda: RAY_SERVE_LOG_ENCODING, |
A little easier to read IMO :)
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.
I think this can actually just be RAY_SERVE_LOG_ENCODING
, no need for the factory
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.
Yea, I tried default= RAY_SERVE_LOG_ENCODING
initially, but patching and reloading modules correctly in pytest is almost impossible 😅
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.
Got it 👍
python/ray/serve/schema.py
Outdated
description=( | ||
"Encoding type for the serve logs. Default to 'TEXT'. 'JSON' is also " | ||
"supported to format all serve logs into json structure." | ||
"Encoding type for the serve logs. Default to 'TEXT'. The default can be " |
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.
"Encoding type for the serve logs. Default to 'TEXT'. The default can be " | |
"Encoding type for the serve logs. Defaults to 'TEXT'. The default can be " |
python/ray/serve/schema.py
Outdated
"supported to format all serve logs into json structure." | ||
"Encoding type for the serve logs. Default to 'TEXT'. The default can be " | ||
"overwritten using the `RAY_SERVE_LOG_ENCODING` environment variable. " | ||
"'JSON' is also supported to format all serve logs into json structure." |
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.
"'JSON' is also supported to format all serve logs into json structure." | |
"'JSON' is also supported for structured logging." |
Signed-off-by: Gene Su <e870252314@gmail.com>
@edoakes this is ready for merge |
Why are these changes needed?
We want a way to be able to use environment variables to setup Serve's structured json logging on the platform. Add
RAY_SERVE_LOG_ENCODING_ENV
env to set the global logging behavior for Serve.Related issue number
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.