github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/examples/python/simple/main.py (about)

     1  #!/usr/bin/env python3
     2  
     3  import os
     4  
     5  import pyroscope
     6  
     7  pyroscope.configure(
     8  	application_name       = "simple.python.app",
     9  	server_address = "http://pyroscope:4040",
    10  )
    11  
    12  def work(n):
    13  	i = 0
    14  	while i < n:
    15  		i += 1
    16  
    17  def fast_function():
    18  	with pyroscope.tag_wrapper({ "function": "fast" }):
    19  		work(20000)
    20  
    21  def slow_function():
    22  	with pyroscope.tag_wrapper({ "function": "slow" }):
    23  	    work(80000)
    24  
    25  if __name__ == "__main__":
    26  	while True:
    27  		fast_function()
    28  		slow_function()