Append filename and lineno for logs#54433
Conversation
2abd173 to
b72517e
Compare
|
Hi @ashb I could verify that the both test failure is because of the format change of event section in json. Do you think it's reasonable to directly ovewrite event here? |
b72517e to
bf12fd5
Compare
ashb
left a comment
There was a problem hiding this comment.
Thank you for picking this up, but this approach is not right.
This is combining capturing and presentation into the capture phase which is not right. This needs to be re-worked to a) not be a performance hit, and b) To correctly take advantage of having structured logs.
In short: log_format should be a presentation time that the UI deals with, not something that actually affects how the JSON logs are written.
|
In short -- I'm tempted to say that log_format should actually be removed and retconned as a breaking change in 3.0. |
bf12fd5 to
0823192
Compare
Hi @ashb thanks so much for taking a look at this! Instead of replying all comments, I'll reply you here:
|
0823192 to
8b591e6
Compare
8b591e6 to
33feeba
Compare
33feeba to
1437662
Compare
|
Hi @ashb I updated this pr. Could you please take a look again? Thanks! |
| def add_callsite_parameter(logger: Any, method_name: Any, event_dict: EventDict) -> EventDict: | ||
| record = event_dict.get("_record", None) | ||
| if record: | ||
| event_dict["filename"] = record.__dict__["pathname"] | ||
| event_dict["lineno"] = record.__dict__["lineno"] | ||
| return event_dict |
There was a problem hiding this comment.
This will only for for log messages that come from stdlib logging.
Instead we should use https://www.structlog.org/en/stable/api.html#structlog.processors.CallsiteParameterAdder which will handle that case, and the native structlog ones for us.
related: #54145
After using structlog, we didn't log the callsite info. In this pr, we added a processor to collect filename and lineno callsite info.
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.