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

Add Profile function #155

Merged
merged 12 commits into from
Aug 22, 2021
Merged

Add Profile function #155

merged 12 commits into from
Aug 22, 2021

Conversation

Humbertzhang
Copy link
Member

@Humbertzhang Humbertzhang commented Aug 21, 2021

This is PR is for Google Summer Of Code 2021 Project: Proposal for Apache SkyWalking: Python agent supports profiling
I will add test for profile function after GSoC is over.

This PR is the rest part of apache/skywalking#5943 following #127 .

It added the profile function into Python Agent, I tested it in normal and concurrent scenario and it works fine.

@Humbertzhang Humbertzhang added core feature New feature labels Aug 21, 2021
@Humbertzhang Humbertzhang added this to the 0.7.0 milestone Aug 21, 2021
Copy link
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very amazing! I tested it and the result look like below.

Just some minor comments

The tested codes is

def method1():
    time.sleep(0.02)
    return '1'

def method2():
    time.sleep(0.02)
    return method1()

def method3():
    time.sleep(0.02)
    return method2()

if __name__ == '__main__':
    config.service_name = 'provider'
    config.logging_level = 'DEBUG'
    agent.start()

    import socketserver
    from http.server import BaseHTTPRequestHandler

    class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):

        def do_POST(self):
            method3()
            time.sleep(0.5)
            self.send_response(200)
            self.send_header('Content-Type', 'application/json')
            self.end_headers()
            self.wfile.write('{"song": "Despacito", "artist": "Luis Fonsi"}'.encode('ascii'))

    PORT = 9091
    Handler = SimpleHTTPRequestHandler

    with socketserver.TCPServer(("", PORT), Handler) as httpd:
        httpd.serve_forever()

Screen Shot 2021-08-22 at 10 46 35

skywalking/profile/profile_service.py Show resolved Hide resolved
skywalking/profile/profile_service.py Outdated Show resolved Hide resolved
skywalking/profile/profile_context.py Outdated Show resolved Hide resolved
skywalking/profile/profile_context.py Outdated Show resolved Hide resolved
skywalking/profile/profile_service.py Outdated Show resolved Hide resolved
Copy link
Member

@kezhenxu94 kezhenxu94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!! 🎉

@kezhenxu94 kezhenxu94 merged commit 97bf7fd into apache:master Aug 22, 2021
@kezhenxu94
Copy link
Member

@Humbertzhang please consider adding tests for this feature later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants