-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[Core] Enable Users to Configure Python Standard Log Attributes #49871
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Mengjin Yan <[email protected]>
…sible Signed-off-by: Mengjin Yan <[email protected]>
Signed-off-by: Mengjin Yan <[email protected]>
# Should be marked as @abstractmethod, but we can't do that because of backwards | ||
# compatibility. |
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.
We don't need to consider backward compatibility here as LoggingConfigurator is not a public thing.
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.
Unfortunately, we need to consider the backward compatibility here because rayturbo extend this class as well.
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.
Then can we just add the extra param to it?
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.
Rayturbo we can change as well so it's not an issue.
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.
That's right. The only thing is if we add the @abstractmethod
now, the build will fail after the the PR merged to RayTurbo because the configurator class in RayTurbo doesn't have the method override.
To solve this, I'm planning to have 2 followup PRs:
(1) After the current PR is merged to RayTurbo, I'll update the the configurator class in RayTurbo, override configure_logging_settings
function and remove the previous configure_logging
function
(2) Update OSS to cleanup the configure_logging
function and add @abstractmethod
to the configure_logging_settings
function to only keep the new function.
In this sense, we can migrate all the configure_logging
with configs listed in function parameters to configure_logging_settings
function with configs in the data class.
@@ -17,9 +18,17 @@ def get_supported_encodings(self) -> Set[str]: | |||
raise NotImplementedError | |||
|
|||
@abstractmethod | |||
@Deprecated |
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.
why deprecating this one?
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'm thinking as we add one more field in the config, we should make sure all log fields are configured. So deprecating the previous function that only takes in 2 fields.
{ | ||
"encoding": encoding, | ||
"log_level": log_level, | ||
"addl_log_std_attrs": [], |
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's addl
?
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.
addl
means "additional". As suggested by Ruiyang above, I'll update to whole word to avoid confusion
…_standard_attrs; (2) add LoggingConfigData to pass the parameters to LoggingConfigurator; (3) Update the new method name in LoggingConfigurator to avoid duplicate function name; (4) Add more commens Signed-off-by: Mengjin Yan <[email protected]>
class LoggingConfigData: | ||
encoding: str | ||
log_level: str | ||
additional_log_standard_attrs: list |
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.
why do we need 2 separate classes: LoggingConfigData and LoggingConfig? I mean, can we just pass the public LoggingConfig to the Configurator?
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.
We can't because otherwise, there will be circular dependency between LoggingConfig
and LoggingConfigurator
.
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.
Can you tell me more about the circular dependency?
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.
Synced offline. Will leverage the python's forward declaration for types to avoid adding an additional LoggingConfigData
class.
Signed-off-by: Mengjin Yan <[email protected]>
Signed-off-by: Mengjin Yan <[email protected]>
Signed-off-by: Mengjin Yan <[email protected]>
record_format_attrs[LogKey.TIMESTAMP_NS.value] = record_format_attrs.pop( | ||
INTERNAL_TIMESTAMP_LOG_KEY | ||
) | ||
class AbstractFormatter(logging.Formatter, ABC): |
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 don't see any abstract methods
class LoggingConfigData: | ||
encoding: str | ||
log_level: str | ||
additional_log_standard_attrs: list |
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.
Can you tell me more about the circular dependency?
…eak circular depencency; 2. add format as the abstract method in AbstractFormatter Signed-off-by: Mengjin Yan <[email protected]>
Signed-off-by: Mengjin Yan <[email protected]>
Why are these changes needed?
This PR enables user to configure a list of additional standard python logging attributes so that the fields can be included in the log recored in for both plain text and structured logging.
It adds an additional field
addl_log_std_attrs
in the existingray.LoggingConfig
. Theaddl_log_std_attrs
takes in a list of field names and add the fields & its value to the log line when formatting the log line.Corresponding tests are added as well.
Related issue number
#49502
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.