skywalking icon indicating copy to clipboard operation
skywalking copied to clipboard

[Bug] Python agent’s @runnable does not behave as expected

Open xlq20080808 opened this issue 1 year ago • 0 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Apache SkyWalking Component

Python Agent (apache/skywalking-python)

What happened

python version : 3.11.4 python agent : v1.0.1 flask version: 2.3.0

demo image

cross threads are not in one trace image

What you expected to happen

Cross threads in one trace As shown below image

How to reproduce

@app.route("/")
def hello():
    thread = threading.Thread(target=post)
    thread.start()
    return "ok"

@runnable(op="/post")
def post():
    return "post ok"

Anything else

1、 when the service is started, it will try to obtain a snapshot before making method calls. The behavior is expected for an interpreted language like python. image But when the method is actually executed, an None snapshot will cause the trace to interrupt. image 2、 After checking the test cases, the writing method in the picture below can behave as expected. Each method call triggers snapshot = get_context().capture() image But we cannot require users to write this way

Are you willing to submit a pull request to fix on your own?

  • [ ] Yes I am willing to submit a pull request on my own!

Code of Conduct

xlq20080808 avatar Nov 28 '23 13:11 xlq20080808