cBiscuitSurprise commented on issue #25019:
URL: https://github.com/apache/airflow/issues/25019#issuecomment-1741438402
I would like to give this issue a try.
We have the option to override the default-json serializer to whatever we
want. I would propose that we override this to preserve the 2.x behavior with a
config option to allow opt-in to the new `repr` format using
`logging.REMOTE_LOG_KWARGS` (a new config). This way we can upgrade to 3.x, but
keep the old serializer.
```python
def json_serialize_legacy(o):
"""
The legacy `[email protected]` json serializer function that serialized
datetime objects as ISO format andall other non-JSON-serializable to
`null`
"""
if isinstance(o, (date, datetime)):
return o.isoformat()
...
class CloudwatchTaskHandler(FileTaskHandler, LoggingMixin):
...
def __init__(self, base_log_folder: str, log_group_arn: str,
filename_template: str | None = None):
...
remote_log_options: Dict[str, Any] = conf.get("logging",
"REMOTE_LOG_KWARGS", {})
self.opt_in_new_json_serialize =
remote_log_options.get("opt_in_new_json_serialize", False)
...
def set_context(self, ti):
super().set_context(ti)
self.handler = watchtower.CloudWatchLogHandler(
...
json_serialize_default=None if self.opt_in_new_json_serialize
else json_serialize_legacy,
)
```
This is my first interaction with this project, so I understand if it's not
desirable to add config like this, just brainstorming. Let me know what you
guys think.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]