Skip to content

Ruby

Instrumenting your existing Ruby application with the OpenTelemetry SDK gives you the flexibility to capture custom metrics, manual spans, and tailored application context.

Add the OpenTelemetry SDK and OTLP exporter to your Gemfile:

gem 'opentelemetry-sdk'
gem 'opentelemetry-exporter-otlp'

Then install the gems:

bundle install

Configure the OpenTelemetry exporter to send data to the KloudMate Agent’s OTLP endpoint. By default, the KloudMate agent listens on port 4318 for HTTP OTLP traffic.

You can configure the endpoint via environment variables before running your instrumented code:

export OTEL_EXPORTER_OTLP_ENDPOINT="http://KM_AGENT_HOST:4318"
export OTEL_SERVICE_NAME="your-ruby-service"

(Replace KM_AGENT_HOST with the IP address or hostname of your KloudMate Agent).

OpenTelemetry is continuously evolving. For the most up-to-date SDK instructions, advanced configurations, and custom instrumentation details, refer to the official OpenTelemetry documentation:


Looking for a step-by-step tutorial?
Check out our Instrument a Ruby App guide to see how to manually instrument a simple Ruby application.