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.