Skip to main content

Ruby

Ruby is fully supported by Speedscale. Use this page for Ruby-specific proxy settings, TLS trust configuration, demo guidance, and the proxymock local workflow.

Kubernetes Sidecar​

When Ruby runs with the Speedscale sidecar in forward or dual mode, the Ruby runtime must still send outbound traffic to the sidecar. Set HTTP_PROXY and HTTPS_PROXY to http://127.0.0.1:4140 unless you changed proxy-out-port. Ruby's standard-library Net::HTTP reads these variables by default.

If tls-out is enabled, trust and routing are separate concerns:

  • routing: HTTP_PROXY and HTTPS_PROXY
  • TLS trust: SSL_CERT_FILE or the language-specific trust mechanism in your image

See Proxy Modes and TLS Support for the shared sidecar behavior.

Demo App​

  • Public demo: speedscale/mock-lab (languages/ruby directory)
  • Stack: Ruby HTTP service using the standard-library Net::HTTP client that calls one downstream, the CNCF projects API at https://demo-api.trafficreplay.com
  • Local run: ruby app.rb
  • Quick validation: ./lab/tests/run_tests.sh --recording

This is the canonical public Ruby demo for the proxymock quickstart and local replay workflow.

proxymock​

Use this path for the fastest Ruby first success on a developer workstation.

  1. 1. Install and initialize proxymock
    brew install speedscale/tap/proxymock
    proxymock init

    Use browser sign-in by default. Use `proxymock init --api-key <your key>` only for CI or other headless environments.

  2. 2. Start recording
    git clone https://github.com/speedscale/mock-lab
    cd mock-lab/languages/ruby
    proxymock record -- ruby app.rb

    proxymock records the app while it starts the Ruby service as a child process. `Net::HTTP` reads the proxy environment variables proxymock sets, so no extra configuration is needed.

  3. 3. Generate one real workflow
    ./lab/tests/run_tests.sh --recording

    Run the test driver from the repo root. It drives the requests that become the exported production-style trace.

  4. 4. Stop the recording, then run with mocks
    cd mock-lab/languages/ruby
    proxymock mock -- ruby app.rb

    The mocked run should no longer need live outbound dependencies.

  5. 5. Replay the same traffic against a change
    cd mock-lab/languages/ruby
    proxymock replay --test-against http://localhost:8080

    Use replay as the regression check before shipping Ruby changes.

TLS Trust​

Ruby's Net::HTTP honors SSL_CERT_FILE for trusting the proxymock CA during TLS interception. See the shared Language Configuration page for the exact command and related options.