Uh oh!
There was an error while loading. Please reload this page.
Rework remote task log handling for the structlog era. - #48491
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
e25bd96 to
e43c7bbCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
eladkal
commented
Apr 1, 2025
Does this affect elasticsearch / opensearch logging? asking because I don't see changes in this PR for these providers |
ashb
commented
Apr 1, 2025
Oh yes, I forgot to deal with this. My plan for now is to make it fall back to the existing airflow.task handler. (I also really don't like we have two almost identical providers for ES and OS. Thanks a lot Elastic. |
Previously this feature was built on top of the stdlib logging.Handler interface, and it worked but had a few issues (even before we switched to structlog for Task SDK): - we had to use what is in many ways a hack with the "set_context" to get information down in to the task handler. - Discovering of the configured task handler was somewhat baroque - The whole thing is just complex due to the features of stdlib logging (loggers, propagate, handler levels etc etc.) - The upload was triggered somewhat "automatically" inside close, which from an abstraction point of view is messy. This changes things to have a more explicit interface purpose made for uploading task log files and for reading them, and perhaps more crucially for things like CloudWatch Logs, it (re)adds the ability to install a structlog processor that will receive every log message as it happens. The return types for the read et al functions were confusing the living daylights out of me, so I've created type alias to give the return types explicit names to reduce (my) confusion.
eladkal
commented
Apr 2, 2025
We are missing handling for HdfsTaskHandler but I believe this is a niche one and we can do it later. created #48685 to followup |
ashb
commented
Apr 2, 2025
mypy providers failure is fixed in #48686 |
ashb
commented
Apr 2, 2025
I haven't changed deps, everything but lowest provider deps is passing, so I'm merging this now. |
Uh oh!
There was an error while loading. Please reload this page.
jason810496
commented
Apr 3, 2025
I think |
ashb
commented
Apr 3, 2025
@jason810496 ES and OS are a bit of a mess tbh. They are entirely too specialized, and 95% of that isn't needed anymore now that Task SDK writes out JSON logs natively. |
eladkal
commented
Apr 3, 2025
We can decide that these two providers (Elastic, open search) would be Airflow 3+ compatible from next release. |
Previously this feature was built on top of the stdlib logging.Handler interface, and it worked but had a few issues (even before we switched to structlog for Task SDK): - we had to use what is in many ways a hack with the "set_context" to get information down in to the task handler. - Discovering of the configured task handler was somewhat baroque - The whole thing is just complex due to the features of stdlib logging (loggers, propagate, handler levels etc etc.) - The upload was triggered somewhat "automatically" inside close, which from an abstraction point of view is messy. This changes things to have a more explicit interface purpose made for uploading task log files and for reading them, and perhaps more crucially for things like CloudWatch Logs, it (re)adds the ability to install a structlog processor that will receive every log message as it happens. The return types for the read et al functions were confusing the living daylights out of me, so I've created type alias to give the return types explicit names to reduce (my) confusion.
Previously this feature was built on top of the stdlib logging.Handler interface, and it worked but had a few issues (even before we switched to structlog for Task SDK): - we had to use what is in many ways a hack with the "set_context" to get information down in to the task handler. - Discovering of the configured task handler was somewhat baroque - The whole thing is just complex due to the features of stdlib logging (loggers, propagate, handler levels etc etc.) - The upload was triggered somewhat "automatically" inside close, which from an abstraction point of view is messy. This changes things to have a more explicit interface purpose made for uploading task log files and for reading them, and perhaps more crucially for things like CloudWatch Logs, it (re)adds the ability to install a structlog processor that will receive every log message as it happens. The return types for the read et al functions were confusing the living daylights out of me, so I've created type alias to give the return types explicit names to reduce (my) confusion.
Previously this feature was built on top of the stdlib logging.Handler interface, and it worked but had a few issues (even before we switched to structlog for Task SDK): - we had to use what is in many ways a hack with the "set_context" to get information down in to the task handler. - Discovering of the configured task handler was somewhat baroque - The whole thing is just complex due to the features of stdlib logging (loggers, propagate, handler levels etc etc.) - The upload was triggered somewhat "automatically" inside close, which from an abstraction point of view is messy. This changes things to have a more explicit interface purpose made for uploading task log files and for reading them, and perhaps more crucially for things like CloudWatch Logs, it (re)adds the ability to install a structlog processor that will receive every log message as it happens. The return types for the read et al functions were confusing the living daylights out of me, so I've created type alias to give the return types explicit names to reduce (my) confusion.
…g config When remote_task_handler_kwargs contains FileTaskHandler parameters like max_bytes, backup_count, or delay, these were incorrectly passed to RemoteLogIO constructors (e.g., WasbRemoteLogIO, S3RemoteLogIO) which don't accept them, causing TypeError on startup. This was a regression introduced when RemoteLogIO classes were split out from the handlers in PR apache#48491. The remote_task_handler_kwargs dict was passed entirely to RemoteLogIO and then cleared, so handler-level params were never applied to the FileTaskHandler. The fix separates the kwargs: handler-specific parameters (max_bytes, backup_count, delay) are preserved and applied to the handler config, while the remaining kwargs are passed to the RemoteLogIO constructor. Closes: apache#58770
…g config When remote_task_handler_kwargs contains FileTaskHandler parameters like max_bytes, backup_count, or delay, these were incorrectly passed to RemoteLogIO constructors (e.g., WasbRemoteLogIO, S3RemoteLogIO) which don't accept them, causing TypeError on startup. This was a regression introduced when RemoteLogIO classes were split out from the handlers in PR apache#48491. The remote_task_handler_kwargs dict was passed entirely to RemoteLogIO and then cleared, so handler-level params were never applied to the FileTaskHandler. The fix separates the kwargs: handler-specific parameters (max_bytes, backup_count, delay) are preserved and applied to the handler config, while the remaining kwargs are passed to the RemoteLogIO constructor. Closes: apache#58770
Previously this feature was built on top of the stdlib logging.Handler
interface, and it worked but had a few issues (even before we switched to
structlog for Task SDK):
information down in to the task handler.
(loggers, propagate, handler levels etc etc.)
an abstraction point of view is messy.
This changes things to have a more explicit interface purpose made for
uploading task log files and for reading them, and perhaps more crucially for
things like CloudWatch Logs, it (re)adds the ability to install a structlog
processor that will recieve every log message as it happens.
The return types for the read et al functions were confusing the living
daylights out of me, so I've created type alias to give the return types
explicit names to reduce (my) confusion.