Uh oh!
There was an error while loading. Please reload this page.
Add log grouping using summary and details tag. - #46820
Conversation
jscheffl
commented
Feb 17, 2025
The syntax with
I think this is OK. |
jscheffl
left a comment
There was a problem hiding this comment.
The PR Looks promising. Do you have a DAG which might be good for testing?
Before I manually test, does it support nested grouping? (Github does not and I was always proud Airflow does. Code looks like but have not checked.
When I made the implementation in Airflow 2 I made some tests that a browser is not killed by OOM or freezing if the logs are long. Have you tested with a 100MB log file with some groups before / after? Any performance difference that you could see?
(If you have positive answers then I don't need to test myself :-D)
Uh oh!
There was an error while loading. Please reload this page.
tirkarthi
commented
Feb 18, 2025
Thanks @jscheffl for the review. Glad to have the points since you implemented it in Airflow 2.
Supporting Azure would involve using regex and another branch along with handling of mix match between github and azure which will make this implementation complex.
Nested groups are unfortunately not supported at the moment since I go through each line and then add it to an array to empty it once the group ends. Nested groups might take something like a stack of lines to push and pop along with embedding the summary and details tag correctly inside. I have added a todo about the same. I used the below dag to generate logs of various sizes from 1 to 80 MB and I don't see unexpected delay other than few seconds of delay to render the larger log files in the UI along with downloading. Speaking of this there used to be a limit for larger logs in old UI with a download button to view it. Download button was also handy tool for offline views and analysis which is missing in the new UI currently. I guess this is good enough for an initial implementation and can always be iterated through later since we use this feature very much internally to handle logs. fromdatetimeimportdatetimeimportuuidfromairflowimportDAGfromairflow.decoratorsimporttaskwithDAG(
dag_id="log_grouping",
start_date=datetime(2025, 2, 1),
catchup=False,
schedule=None,
) asdag:
@taskdefgenerate(**context):
line_limit=int(context["params"]["line_limit"])
group_limit=int(context["params"]["group_limit"])
print("::group::group name")
forindexinrange(group_limit):
print(f"::group::inner group name {index}")
forindexinrange(line_limit):
print(" ".join([uuid.uuid4().hex] *1))
print("::endgroup::")
print("::endgroup::")
generate() |
bbovenzi
commented
Feb 18, 2025
I think we need to make sure this is compatible with the log handler changes here: #46827 |
tirkarthi
commented
Feb 18, 2025
Thanks, whichever gets merged first I can try to fix the compatibility issues. I guess color highlighting based on keywords is also easier since I just need to add |
jscheffl
commented
Feb 18, 2025
I'd for sure strongly nested grouping - but I would assume this can be added later as well. I think this is a very big shortcoming in Github and I was a big fan that Airflow had this in. Airflow 2 also went over the logs line-by-line. Don't know if you checked the old implementation. Do you think this could be factored-in? |
tirkarthi
commented
Feb 19, 2025
Thanks, I checked it. From what I understand in Airflow 2 manually created span tags appending to each other and used |
jscheffl
left a comment
There was a problem hiding this comment.
Accept it as intermediate state. Hoping that nested grouping is added later. Don't know when I'd be ablde to make it myself... so if somebody else would be able...
I assume approach would be simplest by implementing via a recusive call.
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.
bbovenzi
commented
Feb 27, 2025
Let's rebase. |
tirkarthi
commented
Feb 27, 2025
I rebased and with structlog rendering I guess I might need to start from scratch on the implementation :( |
bbovenzi
commented
Feb 27, 2025
I was afraid that change was going to be hard to rebase against. @Lee-W Do you know the answer to this question? I think regardless we need to check the logMessage string or |
Lee-W
commented
Feb 28, 2025
In the latest change, we make StructuredLogMessage(event="::group::Log message source details", sources=source_list), # type: ignore[call-arg]StructuredLogMessage(event="::endgroup::"),This logic is implemented in |
tirkarthi
commented
Feb 28, 2025
@Lee-W Sorry, by normal log I meant the Airflow 2.x logs which were mostly just string. |
Lee-W
commented
Mar 1, 2025
I think we'll need to check the content like Brent suggested |
tirkarthi
commented
Mar 2, 2025
Ok, I rebased and tried an approach here which would be to let Current screenshot |
tirkarthi
commented
Mar 2, 2025
Strangely |
tirkarthi
commented
Mar 2, 2025
The default timeout for https://testing-library.com/docs/dom-testing-library/api-async/#waitfor |
bbovenzi
commented
Mar 3, 2025
I think the screenshot you have there looks good. Nice catch on the timeout. |
bbovenzi
commented
Mar 3, 2025
tirkarthi
commented
Mar 3, 2025
Task sdk logs render the event which has group name along with any other key=value pair as single string so while parsing this after the concatenation looks like the actual log group name. The concatenation and grouping are done in different functions. Not sure how to fix it. |
bbovenzi
left a comment
There was a problem hiding this comment.
Rebase and otherwise lgtm
* Add log grouping using summary and details tag. * Add tests. * Group logs after render elements for the log is processed. * Fix tests and update log response payload. * Increase timeout from 1s to 10s.
* Add log grouping using summary and details tag. * Add tests. * Group logs after render elements for the log is processed. * Fix tests and update log response payload. * Increase timeout from 1s to 10s.


We extensively use log grouping in Airflow 2. While looking at implementation of grouping through a prism plugin to support colors I found about
<details>and<summary>tag which has good browser support supporting almost all browsers in last 5 years.The implementation is to keep the group name under
<details>and to have the group's log content under<summary>section which can be clicked to expand like Airflow 2. The PR involves looking for "::group::" in the log line to indicate the log group start marker and collect the subsequent lines till line with "::endgroup::" is reached and wrap them up in the<details>tag as a section. The code logic and styling around this can be improved but I felt this is a good enough to open a PR for discussion. This also makes the implementation simpler compared to Airflow 2.Docs : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details
Notes to reviewer and self