github.com/grafana/pyroscope@v1.18.0/examples/language-sdk-instrumentation/ruby/simple/main.rb (about)

     1  require "pyroscope"
     2  
     3  Pyroscope.configure do |config|
     4    config.application_name = "test.ruby.app"
     5    config.server_address = "http://pyroscope:4040/"
     6    config.tags = {
     7      :region => "us-east",
     8      :hostname => ENV["HOSTNAME"]
     9    }
    10  end
    11  
    12  def work(n)
    13    i = 0
    14    while i < n
    15      i += 1
    16    end
    17  end
    18  
    19  def fast_function
    20    Pyroscope.tag_wrapper({ "function" => "fast" }) do
    21      work(20000)
    22    end
    23  end
    24  
    25  def slow_function
    26    Pyroscope.tag_wrapper({ "function" => "slow" }) do
    27      work(80000)
    28    end
    29  end
    30  
    31  while true
    32    fast_function
    33    slow_function
    34  end