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 #157

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def main():
except OSError:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('', config.listen_port))
server.server.run(workers=WORKER_NUMBER,
server.server.run(workers=1,
sock=sock,
protocol=sanic_logger.DFHttpProtocol)

Expand Down
8 changes: 7 additions & 1 deletion app/app/application/application.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from sanic import Blueprint
from sanic.response import json as Response
from log import logger
import cProfile

from common.utils import json_response, format_response, app_exception, curl_perform
from common.const import API_PREFIX, HTTP_OK
Expand All @@ -21,9 +22,12 @@
async def application_log_l7_tracing(request):
args = FlowLogL7Tracing(request.json)
args.validate()

pr = cProfile.Profile()
pr.enable()
status, response, failed_regions = await L7FlowTracing(
args, request.headers).query()
pr.disable()
pr.dump_stats('profile_results.prof')
response_dict, code = format_response("Flow_Log_L7_Tracing", status,
response, args.debug, failed_regions)
return Response(json_response(**response_dict),
Expand All @@ -38,8 +42,10 @@ async def application_log_l7_tracing(request):
async def l7_flow_app_tracing(request):
args = TracingCompletionByExternalAppSpans(request.json)
args.validate()

status, response, failed_regions = await TracingCompletion(
args, request.headers).query()

response_dict, code = format_response(
"tracing-completion-by-external-app-spans", status, response,
args.debug, failed_regions)
Expand Down
Loading