Troubleshooting in Python

trace module

You can do several things with trace:

  1. Produce a code coverage report to see which lines are run or skipped over (python3 -m trace –count trace_example/main.py).
  2. Report on the relationships between functions that call one other (python3 -m trace –listfuncs trace_example/main.py | grep -v importlib).
  3. Track which function is the caller (python3 -m trace –listfuncs –trackcalls trace_example/main.py | grep -v importlib).

Application performance monitoring (APM) tools that fit

Datadog in my production

What part of the code should I profile?

The term “profiling” is mainly used for performance testing, and the purpose of performance testing is to find bottlenecks by doing deep analysis.

Typically, we profile:

  • Method or function (most common)
  • Lines (similar to method profiling, but doing it line by line)
  • Memory (memory usage)

What metrics should I profile?

  • Speed (time)
  • Calls (frequency)
  • Method and line profiling

References

SuperMade with Super