Skip to content

Commit

Permalink
Add profile
Browse files Browse the repository at this point in the history
**Phenomenon and reproduction steps**

**Root cause and solution**

**Impactions**

**Test method**

**Affected branch(es)**

* main

**Checklist**

- [ ] Dependencies update required
- [ ] Common bug (similar problem in other repo)
  • Loading branch information
xiaochaoren1 committed Jan 16, 2024
1 parent 21ed93a commit 322fca2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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

0 comments on commit 322fca2

Please sign in to comment.