Skip to main content
The HyperProbe Ruby SDK runs as an in-process agent for standard Ruby (CRuby) and JRuby. It captures variable snapshots, stack frames, metrics, and logs without adding logging statements to your application. Capture overhead depends on your probes and workload.

Technical Prerequisites

  • Standard Ruby (CRuby): Ruby 3.0 and later.
  • JRuby (Ruby on JVM): JRuby 9.3 and later on Java 11 or later (Java 17, 21, and 25 supported). Requires the JIT-preserving tracing profile in JRUBY_OPTS.
  • Metadata: Access to the active git commit SHA (mandatory for matching local source coordinates to production builds).

Installation

Add the SDK as a dependency using your package manager:
If you added gem 'hyperprobe-agent' directly to your Gemfile, run:

Initialization Walkthrough

Follow these steps to initialize the HyperProbe agent inside your application:
1

Create your initialization file

Create a dedicated file named hyperprobe.rb in your project root:
hyperprobe.rb
2

Import it in your entrypoint

In your main application entrypoint (such as config/environment.rb for Rails, or app.rb / server.rb for Sinatra / Rack), require hyperprobe as early as possible before starting your application:
Environment Variables Loading Order: If hyperprobe.rb reads variables loaded by a library such as dotenv, load those variables before requiring hyperprobe.rb.
3

Configure multi-worker servers (Puma / Unicorn)

If you run a multi-process web server like Puma or Unicorn in clustered mode (with forked workers) on standard Ruby (CRuby), add defer_start: true to your initializer and call HyperProbe.after_fork in your worker boot configuration:
config/puma.rb
JRuby on JVM: On JRuby, Puma runs in multi-threaded mode on the JVM without process forking, so HyperProbe.after_fork and defer_start are not required.
4

Configure your Dockerfile

To enable Docker-based deployments, define a GIT_COMMIT build argument inside your Dockerfile with a default value of unknown.If you are running JRuby, also set the JRUBY_OPTS environment variable to preserve variable scopes with JIT enabled:
Dockerfile
5

Run local Docker builds

For building and testing Docker containers locally, inject your active git commit:
6

Inject correct SHA in CI/CD (The PR Merge Trap)

To protect source alignment, HyperProbe refuses to start if commit_sha resolves to unknown. Pass the real commit SHA to GIT_COMMIT during deployment.Always use your CI/CD platform’s native commit SHA variable:
Beware of the PR Merge Commit Trap: By default, GitHub Actions checks out a virtual merge commit for a pull_request trigger instead of the commit from your branch.If you use git rev-parse HEAD or ${{ github.sha }} in a pull request workflow, source mapping can fail. Use ${{ github.event.pull_request.head.sha || github.sha }} for pull request builds.

☕ JRuby Support (Ruby on the JVM)

HyperProbe provides native, first-class support for JRuby applications running on the JVM.

Prerequisites for JRuby

  1. JRuby Version: JRuby 9.3 and later (Java 8 is not supported; JRuby 10.1 requires Java 21+).
  2. Java Runtime: Java 11, 17, 21, or 25.
  3. Launch Profile: JRuby must be launched with the required JIT-preserving tracing profile:

Why the Launch Profile is Required on JRuby

JRuby’s JIT compiler optimizes hot methods into raw JVM bytecode, stripping out line-level checkpoints and local variable names by default. Passing this profile instructs JRuby to retain line checkpoints and local variable scopes without disabling JIT compilation, so probes trigger reliably on compiled methods.

How to Launch JRuby with HyperProbe

Add the environment variable inside your Dockerfile or Deployment manifest:
Dockerfile
Zero C-Extensions & Zero Runtime Downloads: On JRuby, Bundler automatically installs the Java gem artifact (hyperprobe-agent-<version>-java.gem). It bundles an internal, shaded Netty gRPC transport and patched protobuf codec. No C compiler, Maven, or runtime downloads are required on the client machine.

Configuration & Environment Variables Reference

You can configure the agent by passing properties inside your HyperProbe.start() options hash, or by using environment variables. The following example includes the available programmatic options and their corresponding environment variables:
hyperprobe.rb
  • Option Precedence: Explicit options passed to HyperProbe.start() take precedence over environment variables.
  • Disabling the Agent: Set HYPERPROBE_DISABLED=YES in your environment to completely disable the agent at startup.
  • Option Naming: Both snake_case (e.g., service_id, commit_sha) and camelCase (e.g., serviceId, commitSha) parameter keys are accepted.
On CRuby, snapshots include locals from the hit frame and available caller frames, including blocks, up to stack_frame_depth. On JRuby, only the hit frame has locals; caller frames show {}.

Safe evaluation

Safe evaluation is enabled by default on Ruby and JRuby. To allow custom method calls in probe expressions, opt in before starting your application:
Alternatively, add disable_safe_evaluation: true to your existing HyperProbe.start options. An explicit false keeps safe evaluation enabled, even if the environment variable is true.
Disabling safe evaluation lets conditions, watches, log placeholders, metrics, and duration correlations execute Ruby code with your application’s permissions. This code can change state, block, or terminate the process. Only enable it for trusted probes. The SDK logs a warning once at startup when enabled.

Safety shields

The SDK automatically suspends probes when its safety limits are exceeded:
  • CRuby: Uses repeated thread-lag readings and a probe-handler time budget (default 15 ms per second).
  • JRuby: Checks JVM heap headroom every 5 seconds. Below 15% of maximum heap triggers a warning; below 5% suspends probes. Timing-budget breaches do not log warnings or suspend probes.
  • Auto-recovery: Resumes probes after the cooldown period (default 10 seconds), once health returns to GREEN.