Various debugging methods in OpenResty

Click for: original source

In OpenResty’s communication group, developers often ask this question: How do debug in OpenResty? As far as I know, there are some tools in OpenResty that support breakpoint debugging, including a plugin in VSCode, but they are not widely used so far. Including the author agentzh and a few contributors I know, everyone uses the simplest ngx.log and ngx.say to do debugging. By @api7.ai.

In the OpenResty world, SystemTap and flame graph are the standard tools for dealing with tough problems and performance issues. If you have a question about this on a mailing list or issue, the project maintainer will ask you to upload a flame graph and ask for a graphical rather than a textual description.

This article copvers toolset OpenResty created specifically for debugging. We’ll start by looking at what’s available for debugging programs:

  • Breakpoints and print logs
  • Binary search algorithm and comment
  • Dynamic debugging
  • Systemtap
  • Other dynamic tracking frameworks
  • Flame graph

It is essential to know that even a non-intrusive technique like dynamic tracking is not perfect. It can only detect a particular individual process; in general, we only turn it on briefly to use the data sampled during that time. So if you need to detect across multiple services or for long periods, you still need a distributed tracing technique like opentracing. Excellent read!

[Read More]

Tags programming performance devops distributed apis