Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

peschmae
Copy link

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:

  • [N/A ] Example configuration file for the change
  • [x ] Debug log output from testing the change
  • [ N/A] Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [ N/A] Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • [N/A ] Documentation required for this feature

Backporting

  • Backport to latest stable release.

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.

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]>
@peschmae
Copy link
Author

peschmae commented May 26, 2023

Output of valgrind for flt-it-multiline tests

 valgrind ./bin/flb-it-multiline 
==966== Memcheck, a memory error detector
==966== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==966== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==966== Command: ./bin/flb-it-multiline
==966== 
Test parser_docker...                           
----- MULTILINE FLUSH -----
[0] [1612197903.012310000, {}, {"log"=>"aa
", "stream"=>"stdout", "time"=>"2021-02-01T16:45:03.01231z"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1612197903.012310000, {}, {"log"=>"aa
", "stream"=>"stderr", "time"=>"2021-02-01T16:45:03.01231z"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1612197903.012320000, {}, {"log"=>"bbcc
", "stream"=>"stdout", "time"=>"2021-02-01T16:45:03.01232z"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1612197903.012330000, {}, {"log"=>"dd", "stream"=>"stderr", "time"=>"2021-02-01T16:45:03.01233z"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1685104900.835602616, {}, {"log"=>"single line to force pending flush of the previous line"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1612197903.012340000, {}, {"log"=>"ee
", "stream"=>"stderr", "time"=>"2021-02-01T16:45:03.01234z"}]
----------- EOF -----------
==966== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
==966== Warning: invalid file descriptor -1 in syscall close()
Test parser_cri...                              
----- MULTILINE FLUSH -----
[0] [1557255470.904275087, {}, {"time"=>"2019-05-07T18:57:50.904275087+00:00", "stream"=>"stdout", "_p"=>"P", "log"=>"1a. some multiline log"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1557255470.904275087, {}, {"time"=>"2019-05-07T18:57:50.904275087+00:00", "stream"=>"stderr", "_p"=>"P", "log"=>"1b. some multiline log"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1557255473.904275090, {}, {"time"=>"2019-05-07T18:57:53.904275090+00:00", "stream"=>"stdout", "_p"=>"P", "log"=>"2a. another multiline log"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1557255473.904275090, {}, {"time"=>"2019-05-07T18:57:53.904275090+00:00", "stream"=>"stderr", "_p"=>"P", "log"=>"2b. another multiline log"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1557255476.904275093, {}, {"time"=>"2019-05-07T18:57:56.904275093+00:00", "stream"=>"stdout", "_p"=>"F", "log"=>"3a. non multiline 1"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1557255477.904275094, {}, {"time"=>"2019-05-07T18:57:57.904275094+00:00", "stream"=>"stdout", "_p"=>"F", "log"=>"4a. non multiline 2"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1557255476.904275093, {}, {"time"=>"2019-05-07T18:57:56.904275093+00:00", "stream"=>"stderr", "_p"=>"F", "log"=>"3b. non multiline 1"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1557255477.904275094, {}, {"time"=>"2019-05-07T18:57:57.904275094+00:00", "stream"=>"stderr", "_p"=>"F", "log"=>"4b. non multiline 2"}]
----------- EOF -----------
==966== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
==966== Warning: invalid file descriptor -1 in syscall close()
Test parser_java...                             [0] [(ext: 0)"dp\xa9\x044I2\xf7", {"log"=>"Exception in thread "main" java.lang.IllegalStateException: ..null property
"}]
[0] [(ext: 0)"dp\xa9\x044\xc3b\x1a", {"log"=>"     at com.example.myproject.Author.getBookIds(xx.java:38)
"}]
[0] [(ext: 0)"dp\xa9\x044\xe8\xe2\", {"log"=>"     at com.example.myproject.Bootstrap.main(Bootstrap.java:14)
"}]
[0] [(ext: 0)"dp\xa9\x044\xea\xf0\x91", {"log"=>"Caused by: java.lang.NullPointerException
"}]
[0] [(ext: 0)"dp\xa9\x044\xf4\x03\xf8", {"log"=>"     at com.example.myproject.Book.getId(Book.java:22)
"}]
[0] [(ext: 0)"dp\xa9\x044\xf6\xf64", {"log"=>"     at com.example.myproject.Author.getBookIds(Author.java:35)
"}]
[0] [(ext: 0)"dp\xa9\x044\xf8\xa7x", {"log"=>"     ... 1 more
"}]
[0] [(ext: 0)"dp\xa9\x045\x05%\x8d", {"log"=>"single line
"}]

----- MULTILINE FLUSH -----
[0] [1685104900.877212407, {}, {"log"=>"Exception in thread "main" java.lang.IllegalStateException: ..null property
     at com.example.myproject.Author.getBookIds(xx.java:38)
     at com.example.myproject.Bootstrap.main(Bootstrap.java:14)
Caused by: java.lang.NullPointerException
     at com.example.myproject.Book.getId(Book.java:22)
     at com.example.myproject.Author.getBookIds(Author.java:35)
     ... 1 more
"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1685104900.889529741, {}, {"log"=>"single line
"}]
----------- EOF -----------
==966== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
==966== Warning: invalid file descriptor -1 in syscall close()
Test parser_python...                           

----- MULTILINE FLUSH -----
[0] [1685104900.900821533, {}, {"log"=>"Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/data/home/apps/s~nearfieldspy/1.378705245900539993/nearfieldspy.py", line 17, in start
    return get()
  File "/base/data/home/apps/s~nearfieldspy/1.378705245900539993/nearfieldspy.py", line 5, in get
    raise Exception('spam', 'eggs')
Exception: ('spam', 'eggs')
"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1685104900.900821533, {}, {"log"=>"hello world, not multiline
"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1685104900.902741199, {}, {"log"=>"Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
                                ~~~~~~~~^^^^^^^^
  File "/base/data/home/apps/s~nearfieldspy/1.378705245900539993/nearfieldspy.py", line 17, in start
    return get()
  File "/base/data/home/apps/s~nearfieldspy/1.378705245900539993/nearfieldspy.py", line 5, in get
    raise Exception('spam', 'eggs')
                    ^^^^^^
Exception: ('spam', 'eggs')
"}]
----------- EOF -----------
==966== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
==966== Warning: invalid file descriptor -1 in syscall close()
Test parser_ruby...                             

----- MULTILINE FLUSH -----
[0] [1685104900.911856824, {}, {"log"=>"/app/config/routes.rb:6:in `/': divided by 0 (ZeroDivisionError)
        from /app/config/routes.rb:6:in `block in <main>'
        from /var/lib/gems/3.0.0/gems/actionpack-7.0.4/lib/action_dispatch/routing/route_set.rb:428:in `instance_exec'
        from /var/lib/gems/3.0.0/gems/actionpack-7.0.4/lib/action_dispatch/routing/route_set.rb:428:in `eval_block'
        from /var/lib/gems/3.0.0/gems/actionpack-7.0.4/lib/action_dispatch/routing/route_set.rb:410:in `draw'
        from /app/config/routes.rb:1:in `<main>'
"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1685104900.911856824, {}, {"log"=>"hello world, not multiline
"}]
----------- EOF -----------
==966== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
==966== Warning: invalid file descriptor -1 in syscall close()
Test parser_elastic...                          

----- MULTILINE FLUSH -----
[0] [1685104900.922616783, {}, {"log"=>"[some weird test] IndexNotFoundException[no such index]
    at org.elasticsearch.cluster.metadata.IndexNameExpressionResolver....
    at org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.java:133)
    at org.elasticsearch.action.admin.indices.delete.java:75)
"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1685104900.923458324, {}, {"log"=>"another separate log line
"}]
----------- EOF -----------
==966== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
==966== Warning: invalid file descriptor -1 in syscall close()
Test parser_go...                               
----- MULTILINE FLUSH -----
[0] [1685104900.933173866, {}, {"log"=>"panic: my panic

goroutine 4 [running]:
panic(0x45cb40, 0x47ad70)
        /usr/local/go/src/runtime/panic.go:542 +0x46c fp=0xc42003f7b8 sp=0xc42003f710 pc=0x422f7c
main.main.func1(0xc420024120)
        foo.go:6 +0x39 fp=0xc42003f7d8 sp=0xc42003f7b8 pc=0x451339
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc42003f7e0 sp=0xc42003f7d8 pc=0x44b4d1
created by main.main
        foo.go:5 +0x58

goroutine 1 [chan receive]:
runtime.gopark(0x4739b8, 0xc420024178, 0x46fcd7, 0xc, 0xc420028e17, 0x3)
        /usr/local/go/src/runtime/proc.go:280 +0x12c fp=0xc420053e30 sp=0xc420053e00 pc=0x42503c
runtime.goparkunlock(0xc420024178, 0x46fcd7, 0xc, 0x1000f010040c217, 0x3)
        /usr/local/go/src/runtime/proc.go:286 +0x5e fp=0xc420053e70 sp=0xc420053e30 pc=0x42512e
runtime.chanrecv(0xc420024120, 0x0, 0xc420053f01, 0x4512d8)
        /usr/local/go/src/runtime/chan.go:506 +0x304 fp=0xc420053f20 sp=0xc420053e70 pc=0x4046b4
runtime.chanrecv1(0xc420024120, 0x0)
        /usr/local/go/src/runtime/chan.go:388 +0x2b fp=0xc420053f50 sp=0xc420053f20 pc=0x40439b
main.main()
        foo.go:9 +0x6f fp=0xc420053f80 sp=0xc420053f50 pc=0x4512ef
runtime.main()
        /usr/local/go/src/runtime/proc.go:185 +0x20d fp=0xc420053fe0 sp=0xc420053f80 pc=0x424bad
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc420053fe8 sp=0xc420053fe0 pc=0x44b4d1

goroutine 2 [force gc (idle)]:
runtime.gopark(0x4739b8, 0x4ad720, 0x47001e, 0xf, 0x14, 0x1)
        /usr/local/go/src/runtime/proc.go:280 +0x12c fp=0xc42003e768 sp=0xc42003e738 pc=0x42503c
runtime.goparkunlock(0x4ad720, 0x47001e, 0xf, 0xc420000114, 0x1)
        /usr/local/go/src/runtime/proc.go:286 +0x5e fp=0xc42003e7a8 sp=0xc42003e768 pc=0x42512e
runtime.forcegchelper()
        /usr/local/go/src/runtime/proc.go:238 +0xcc fp=0xc42003e7e0 sp=0xc42003e7a8 pc=0x424e5c
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc42003e7e8 sp=0xc42003e7e0 pc=0x44b4d1
created by runtime.init.4
        /usr/local/go/src/runtime/proc.go:227 +0x35

goroutine 3 [GC sweep wait]:
runtime.gopark(0x4739b8, 0x4ad7e0, 0x46fdd2, 0xd, 0x419914, 0x1)
        /usr/local/go/src/runtime/proc.go:280 +0x12c fp=0xc42003ef60 sp=0xc42003ef30 pc=0x42503c
runtime.goparkunlock(0x4ad7e0, 0x46fdd2, 0xd, 0x14, 0x1)
        /usr/local/go/src/runtime/proc.go:286 +0x5e fp=0xc42003efa0 sp=0xc42003ef60 pc=0x42512e
runtime.bgsweep(0xc42001e150)
        /usr/local/go/src/runtime/mgcsweep.go:52 +0xa3 fp=0xc42003efd8 sp=0xc42003efa0 pc=0x419973
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc42003efe0 sp=0xc42003efd8 pc=0x44b4d1
created by runtime.gcenable
        /usr/local/go/src/runtime/mgc.go:216 +0x58
"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1685104900.933173866, {}, {"log"=>"one more line, no multiline
"}]
----------- EOF -----------
==966== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
==966== Warning: invalid file descriptor -1 in syscall close()
Test container_mix...                           
----- MULTILINE FLUSH -----
[0] [1612197903.012310000, {}, {"log"=>"a1
", "stream"=>"stdout", "time"=>"2021-02-01T16:45:03.01231z"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1612197903.012310000, {}, {"log"=>"a2
", "stream"=>"stderr", "time"=>"2021-02-01T16:45:03.01231z"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1612197903.012320000, {}, {"log"=>"bbcc", "stream"=>"stdout", "time"=>"2021-02-01T16:45:03.01232z"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1612197903.012320000, {}, {"log"=>"ddee
", "stream"=>"stderr", "time"=>"2021-02-01T16:45:03.01232z"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1557255472.904275089, {}, {"time"=>"2019-05-07T18:57:52.904275089+00:00", "stream"=>"stdout", "_p"=>"F", "log"=>"single full"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1557255470.904275087, {}, {"time"=>"2019-05-07T18:57:50.904275087+00:00", "stream"=>"stdout", "_p"=>"P", "log"=>"1a. some multiline log"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1557255470.904275087, {}, {"time"=>"2019-05-07T18:57:50.904275087+00:00", "stream"=>"stderr", "_p"=>"P", "log"=>"1b. some multiline log"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1612197903.012340000, {}, {"log"=>"dd-out
", "stream"=>"stdout", "time"=>"2021-02-01T16:45:03.01234z"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1612197903.012340000, {}, {"log"=>"dd-err
", "stream"=>"stderr", "time"=>"2021-02-01T16:45:03.01234z"}]
----------- EOF -----------
==966== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
==966== Warning: invalid file descriptor -1 in syscall close()
Test endswith...                                
----- MULTILINE FLUSH -----
[0] [1685104900.959316199, {}, {"log"=>"1a. some multiline log \
1b. some multiline log
"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1685104900.959549449, {}, {"log"=>"2a. another multiline log\
2b. another multiline log
"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1685104900.959681824, {}, {"log"=>"3a. non multiline 1
"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1685104900.959803116, {}, {"log"=>"4a. non multiline 2
"}]
----------- EOF -----------
==966== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
==966== Warning: invalid file descriptor -1 in syscall close()
Test issue_3817_1...                            
----- MULTILINE FLUSH -----
[0] [1621272901.184675702, {}, {"time"=>"2021-05-17T17:35:01.184675702Z", "stream"=>"stdout", "_p"=>"F", "log"=>"[DEBUG] 1 start multiline - 
1 cont A"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1621272901.184675702, {}, {"time"=>"2021-05-17T17:35:01.184675702Z", "stream"=>"stdout", "_p"=>"F", "log"=>"[DEBUG] 2 start multiline - 
2 cont B"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1685104900.971273699, {}, {"log"=>"another isolated line"}]
----------- EOF -----------
==966== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
==966== Warning: invalid file descriptor -1 in syscall close()
Test issue_4034...                              [0] [(ext: 0)"dp\xa9\x04:\x8e\xe7\xad", {"log"=>"2019-05-07T18:57:50.904275087+00:00 stdout P 1a. some "}]
[0] [(ext: 0)"dp\xa9\x04:\xa5\xfc\x0b", {"log"=>"2019-05-07T18:57:51.904275088+00:00 stdout P multiline "}]
[0] [(ext: 0)"dp\xa9\x04:\xa9\xcbw", {"log"=>"2019-05-07T18:57:52.904275089+00:00 stdout F log"}]

----- MULTILINE FLUSH -----
[0] [1557255470.904275087, {}, {"time"=>"2019-05-07T18:57:50.904275087+00:00", "stream"=>"stdout", "_p"=>"P", "log"=>"1a. some multiline log"}]
----------- EOF -----------
[0] [(ext: 0)"dp\xa9\x04:\xb1\xb9\x17", {"log"=>"2019-05-07T18:57:50.904275087+00:00 stderr P 1b. some "}]
[0] [(ext: 0)"dp\xa9\x04:\xb6\xf0`", {"log"=>"2019-05-07T18:57:51.904275088+00:00 stderr P multiline "}]
[0] [(ext: 0)"dp\xa9\x04:\xba\xf4\xdc", {"log"=>"2019-05-07T18:57:52.904275089+00:00 stderr F log"}]

----- MULTILINE FLUSH -----
[0] [1557255470.904275087, {}, {"time"=>"2019-05-07T18:57:50.904275087+00:00", "stream"=>"stderr", "_p"=>"P", "log"=>"1b. some multiline log"}]
----------- EOF -----------
[0] [(ext: 0)"dp\xa9\x04:\xc1\xfc-", {"log"=>"2019-05-07T18:57:53.904275090+00:00 stdout P 2a. another "}]
[0] [(ext: 0)"dp\xa9\x04:\xc4\xe6n", {"log"=>"2019-05-07T18:57:54.904275091+00:00 stdout P multiline "}]
[0] [(ext: 0)"dp\xa9\x04:\xc7\xe6\x7f", {"log"=>"2019-05-07T18:57:55.904275092+00:00 stdout F log"}]

----- MULTILINE FLUSH -----
[0] [1557255473.904275090, {}, {"time"=>"2019-05-07T18:57:53.904275090+00:00", "stream"=>"stdout", "_p"=>"P", "log"=>"2a. another multiline log"}]
----------- EOF -----------
[0] [(ext: 0)"dp\xa9\x04:\xcfP\xef", {"log"=>"2019-05-07T18:57:53.904275090+00:00 stderr P 2b. another "}]
[0] [(ext: 0)"dp\xa9\x04:\xd28\xc0", {"log"=>"2019-05-07T18:57:54.904275091+00:00 stderr P multiline "}]
[0] [(ext: 0)"dp\xa9\x04:\xd6\x9c\x9c", {"log"=>"2019-05-07T18:57:55.904275092+00:00 stderr F log"}]

----- MULTILINE FLUSH -----
[0] [1557255473.904275090, {}, {"time"=>"2019-05-07T18:57:53.904275090+00:00", "stream"=>"stderr", "_p"=>"P", "log"=>"2b. another multiline log"}]
----------- EOF -----------
[0] [(ext: 0)"dp\xa9\x04:\xdd\x0e\xad", {"log"=>"2019-05-07T18:57:56.904275093+00:00 stdout F 3a. non multiline 1"}]

----- MULTILINE FLUSH -----
[0] [1557255476.904275093, {}, {"time"=>"2019-05-07T18:57:56.904275093+00:00", "stream"=>"stdout", "_p"=>"F", "log"=>"3a. non multiline 1"}]
----------- EOF -----------
[0] [(ext: 0)"dp\xa9\x04:\xe4a\xd7", {"log"=>"2019-05-07T18:57:57.904275094+00:00 stdout F 4a. non multiline 2"}]

----- MULTILINE FLUSH -----
[0] [1557255477.904275094, {}, {"time"=>"2019-05-07T18:57:57.904275094+00:00", "stream"=>"stdout", "_p"=>"F", "log"=>"4a. non multiline 2"}]
----------- EOF -----------
[0] [(ext: 0)"dp\xa9\x04:\xec\xf9\x0f", {"log"=>"2019-05-07T18:57:56.904275093+00:00 stderr F 3b. non multiline 1"}]

----- MULTILINE FLUSH -----
[0] [1557255476.904275093, {}, {"time"=>"2019-05-07T18:57:56.904275093+00:00", "stream"=>"stderr", "_p"=>"F", "log"=>"3b. non multiline 1"}]
----------- EOF -----------
[0] [(ext: 0)"dp\xa9\x04:\xf6n\x9b", {"log"=>"2019-05-07T18:57:57.904275094+00:00 stderr F 4b. non multiline 2"}]

----- MULTILINE FLUSH -----
[0] [1557255477.904275094, {}, {"time"=>"2019-05-07T18:57:57.904275094+00:00", "stream"=>"stderr", "_p"=>"F", "log"=>"4b. non multiline 2"}]
----------- EOF -----------
==966== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
==966== Warning: invalid file descriptor -1 in syscall close()
Test issue_4949...                              

----- MULTILINE FLUSH -----
[0] [1685104901.000747241, {}, {"log"=>"Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/data/home/apps/s~nearfieldspy/1.378705245900539993/nearfieldspy.py", line 17, in start
    return get()
  File "/base/data/home/apps/s~nearfieldspy/1.378705245900539993/nearfieldspy.py", line 5, in get
    raise Exception('spam', 'eggs')
Exception: ('spam', 'eggs')
"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1685104901.000747241, {}, {"log"=>"hello world, not multiline
"}]
----------- EOF -----------

----- MULTILINE FLUSH -----
[0] [1685104901.001590408, {}, {"log"=>"Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
                                ~~~~~~~~^^^^^^^^
  File "/base/data/home/apps/s~nearfieldspy/1.378705245900539993/nearfieldspy.py", line 17, in start
    return get()
  File "/base/data/home/apps/s~nearfieldspy/1.378705245900539993/nearfieldspy.py", line 5, in get
    raise Exception('spam', 'eggs')
                    ^^^^^^
Exception: ('spam', 'eggs')
"}]
----------- EOF -----------
==966== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
==966== Warning: invalid file descriptor -1 in syscall close()
Test issue_5504...                              ==966== Warning: invalid file descriptor -1 in syscall close()
[ OK ]
==966== Warning: invalid file descriptor -1 in syscall close()
SUCCESS: All unit tests have passed.
==966== 
==966== HEAP SUMMARY:
==966==     in use at exit: 0 bytes in 0 blocks
==966==   total heap usage: 23,992 allocs, 23,992 frees, 7,604,971 bytes allocated
==966== 
==966== All heap blocks were freed -- no leaks are possible
==966== 
==966== For lists of detected and suppressed errors, rerun with: -s
==966== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

@peschmae
Copy link
Author

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 One single commit must not include changes to files that are different from the component specified in the subject rule.

If this is the case, I'm happy to split this into multiple commits.

@peschmae
Copy link
Author

I'd argue this change doesn't need documentation since there are no configuration changes needed, and no new features were introduced.

@peschmae peschmae temporarily deployed to pr May 26, 2023 14:48 — with GitHub Actions Inactive
@peschmae peschmae temporarily deployed to pr May 26, 2023 14:48 — with GitHub Actions Inactive
@peschmae peschmae temporarily deployed to pr May 26, 2023 14:48 — with GitHub Actions Inactive
@peschmae peschmae temporarily deployed to pr May 26, 2023 15:16 — with GitHub Actions Inactive
Copy link
Collaborator

@nokute78 nokute78 left a 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)

Copy link
Contributor

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.

@github-actions github-actions bot added the Stale label Dec 17, 2023
@peschmae
Copy link
Author

still relevant

@github-actions github-actions bot removed the Stale label Dec 21, 2023
@b1r3k
Copy link

b1r3k commented Mar 30, 2024

still relevant

do you know why is this stuck for almost a year now? what needs to be done?

@peschmae
Copy link
Author

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

Copy link
Contributor

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.

@github-actions github-actions bot added the Stale label Jun 29, 2024
@github-actions github-actions bot removed the Stale label Aug 16, 2024
@peschmae peschmae closed this Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Python mutltiline support for PEP657/Python3.11
3 participants