-
Notifications
You must be signed in to change notification settings - Fork 1.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
multiline: python: Add support for PEP-657 introduced in Python 3.11 #7485
Conversation
This patch adds an additional rule to the python multiline parser, that matches the fine-grained error locations in tracebacks Signed-off-by: Mathias Petermann <[email protected]>
Output of valgrind for
|
As i've extended the tests for python multiline parser (adding an additional multiline log message example, matching the 3.11 style, while keeping the old message to ensure there's no regression), I'm not sure if my commit breaks the If this is the case, I'm happy to split this into multiple commits. |
I'd argue this change doesn't need documentation since there are no configuration changes needed, and no new features were introduced. |
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.
LGTM.
I tested following script and trace text.
We can get traceback using docker like this.
mkdir tmp
cp /path/to/a.py tmp
sudo docker run -it --rm -v $PWD/tmp:/usr/src/test -w /usr/src/test python:3.11-bookworm python a.py
Python script
def manhattan_distance(point_1, point_2):
return abs(point_1.x - point_2.x) + abs(point_1.y - point_2.y)
p1 = 10
p2 = 20
print(manhattan_distance(p1, p2))
Traceback in python 3.11
Traceback (most recent call last):
File "/usr/src/test/a.py", line 6, in <module>
print(manhattan_distance(p1, p2))
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/test/a.py", line 2, in manhattan_distance
return abs(point_1.x - point_2.x) + abs(point_1.y - point_2.y)
^^^^^^^^^
AttributeError: 'int' object has no attribute 'x'
Traceback in python 3.10
Traceback (most recent call last):
File "/home/taka/a.py", line 6, in <module>
print(manhattan_distance(p1, p2))
File "/home/taka/a.py", line 2, in manhattan_distance
return abs(point_1.x - point_2.x) + abs(point_1.y - point_2.y)
AttributeError: 'int' object has no attribute 'x'
Configuration
[INPUT]
Name tail
path python3.11.trace.txt
read_from_head on
multiline.parser python
[OUTPUT]
Name stdout
Valgrind output using traceback in python 3.11
$ valgrind --leak-check=full bin/fluent-bit -c a.conf
==47400== Memcheck, a memory error detector
==47400== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==47400== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==47400== Command: bin/fluent-bit -c a.conf
==47400==
Fluent Bit v2.1.3
* Copyright (C) 2015-2022 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io
[2023/09/17 10:59:23] [ info] [fluent bit] version=2.1.3, commit=be526c69a3, pid=47400
[2023/09/17 10:59:23] [ info] [storage] ver=1.4.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/09/17 10:59:23] [ info] [cmetrics] version=0.6.1
[2023/09/17 10:59:23] [ info] [ctraces ] version=0.3.1
[2023/09/17 10:59:23] [ info] [input:tail:tail.0] initializing
[2023/09/17 10:59:23] [ info] [input:tail:tail.0] storage_strategy='memory' (memory only)
[2023/09/17 10:59:23] [ info] [input:tail:tail.0] multiline core started
[2023/09/17 10:59:23] [ info] [sp] stream processor started
[2023/09/17 10:59:23] [ info] [output:stdout:stdout.0] worker #0 started
[2023/09/17 10:59:24] [ info] [input:tail:tail.0] inotify_fs_add(): inode=3983091 watch_fd=1 name=python3.11.trace.txt
[0] tail.0: [[1694915963.852496411, {}], {"log"=>"Traceback (most recent call last):
File "/usr/src/test/a.py", line 6, in <module>
print(manhattan_distance(p1, p2))
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/test/a.py", line 2, in manhattan_distance
return abs(point_1.x - point_2.x) + abs(point_1.y - point_2.y)
^^^^^^^^^
AttributeError: 'int' object has no attribute 'x'
"}]
^C[2023/09/17 10:59:25] [engine] caught signal (SIGINT)
[2023/09/17 10:59:25] [ warn] [engine] service will shutdown in max 5 seconds
[2023/09/17 10:59:25] [ info] [input] pausing tail.0
[2023/09/17 10:59:26] [ info] [engine] service has stopped (0 pending tasks)
[2023/09/17 10:59:26] [ info] [input] pausing tail.0
[2023/09/17 10:59:26] [ info] [input:tail:tail.0] inotify_fs_remove(): inode=3983091 watch_fd=1
[2023/09/17 10:59:26] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2023/09/17 10:59:26] [ info] [output:stdout:stdout.0] thread worker #0 stopped
==47400==
==47400== HEAP SUMMARY:
==47400== in use at exit: 0 bytes in 0 blocks
==47400== total heap usage: 1,736 allocs, 1,736 frees, 801,093 bytes allocated
==47400==
==47400== All heap blocks were freed -- no leaks are possible
==47400==
==47400== For lists of detected and suppressed errors, rerun with: -s
==47400== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Valgrind output using traceback in python 3.10
$ valgrind --leak-check=full bin/fluent-bit -c a.conf
==47394== Memcheck, a memory error detector
==47394== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==47394== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==47394== Command: bin/fluent-bit -c a.conf
==47394==
Fluent Bit v2.1.3
* Copyright (C) 2015-2022 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io
[2023/09/17 10:57:43] [ info] [fluent bit] version=2.1.3, commit=be526c69a3, pid=47394
[2023/09/17 10:57:43] [ info] [storage] ver=1.4.0, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/09/17 10:57:43] [ info] [cmetrics] version=0.6.1
[2023/09/17 10:57:43] [ info] [ctraces ] version=0.3.1
[2023/09/17 10:57:43] [ info] [input:tail:tail.0] initializing
[2023/09/17 10:57:43] [ info] [input:tail:tail.0] storage_strategy='memory' (memory only)
[2023/09/17 10:57:43] [ info] [input:tail:tail.0] multiline core started
[2023/09/17 10:57:43] [ info] [sp] stream processor started
[2023/09/17 10:57:43] [ info] [output:stdout:stdout.0] worker #0 started
[0] tail.0: [[1694915864.017504557, {}], {"log"=>"Traceback (most recent call last):
File "/home/taka/a.py", line 6, in <module>
print(manhattan_distance(p1, p2))
File "/home/taka/a.py", line 2, in manhattan_distance
return abs(point_1.x - point_2.x) + abs(point_1.y - point_2.y)
AttributeError: 'int' object has no attribute 'x'
[2023/09/17 10:57:44] [ info] [input:tail:tail.0] inotify_fs_add(): inode=3983179 watch_fd=1 name=python3.10.trace.txt
"}]
^C[2023/09/17 10:57:45] [engine] caught signal (SIGINT)
[2023/09/17 10:57:45] [ warn] [engine] service will shutdown in max 5 seconds
[2023/09/17 10:57:45] [ info] [input] pausing tail.0
[2023/09/17 10:57:46] [ info] [engine] service has stopped (0 pending tasks)
[2023/09/17 10:57:46] [ info] [input] pausing tail.0
[2023/09/17 10:57:46] [ info] [input:tail:tail.0] inotify_fs_remove(): inode=3983179 watch_fd=1
[2023/09/17 10:57:46] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2023/09/17 10:57:46] [ info] [output:stdout:stdout.0] thread worker #0 stopped
==47394==
==47394== HEAP SUMMARY:
==47394== in use at exit: 0 bytes in 0 blocks
==47394== total heap usage: 1,736 allocs, 1,736 frees, 801,094 bytes allocated
==47394==
==47394== All heap blocks were freed -- no leaks are possible
==47394==
==47394== For lists of detected and suppressed errors, rerun with: -s
==47394== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
still relevant |
do you know why is this stuck for almost a year now? what needs to be done? |
Not really, as I got a positive review, but no real follow-up after that... With 3.0 beeing released recently, I'll have to try to find some time and rebase/redo the pull request |
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
This patch adds an additional rule to the python multiline parser, that matches the fine-grained error locations in tracebacks
Fixes #7478
Enter
[N/A]
in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-test
label to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.