Low commit activity in last 3 years
Profiling agent for Google Cloud Profiler
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

ruby-cloud-profiler

An implementation of Google Cloud Profiler for Ruby.

This project is not officially supported or endorsed by Google in any way.

Under the hood, the agent uses Stackprof to collect the profiling data, and then converts it to the pprof format expected by Cloud Profiler. The Cloud Profiler API doesn't have pretty HTML documentation, but is described in the googleapis specification which creates generated code in google-api-ruby-client.

To use, you need to decide what to name your service and you need a Google Cloud project ID:

require 'cloud_profiler_agent'
agent = CloudProfilerAgent::Agent.new(service: 'my-service', project_id: 'my-project-id')
agent.start

This will start a background thread that will merrily poll the Cloud Profiler API to see what kinds of profiles it should collect, and when. Then it will run stackprof, and upload the profiles.

Note: the agent can only profile its own process. If your Ruby application is running from a webserver that forks subprocesses, then you'll need to somehow arrange to start the agent in the subprocess.