How do I instrument my python code?
Question: I'm developing some web apps with the grok framework, and I want to know what
the framework is doing when serving a simple page.

So, what tools are out there to grab such data, and maybe, graph it?


Answer: Python has plenty of built-in reflectivity that could be used for
instrumentation. For example:

    
    
    def hax_all_the_things():
      for x in list(globals()):
        func = globals()[x]
        if callable(func) and not hasattr(func, 'instrumented'):
          globals()[x] = lambda func = func, *args, **kwargs: (
            __import__('sys').stdout.write("HAX\n"), func(*args, **kwargs)
          )[1]
          globals()[x].instrumented = True
    

