Skip to content
Download

Send OpenTelemetry from Rails to your Mac

Ruby instruments Rails, the HTTP clients, and the database from one initializer.

  • Loggerhead is open.
  • You know the effective port. Open Collectors → Loggerhead receiver → Connection and copy the HTTP port. The first workspace uses 4318. See Ports and the effective port.
Gemfile
gem 'opentelemetry-sdk'
gem 'opentelemetry-exporter-otlp'
gem 'opentelemetry-instrumentation-all'

Then run bundle install.

config/initializers/opentelemetry.rb
require 'opentelemetry/sdk'
require 'opentelemetry/instrumentation/all'
OpenTelemetry::SDK.configure do |c|
c.service_name = 'my-rails-app'
c.use_all
end
.env
OTEL_EXPORTER_OTLP_ENDPOINT=http://127.0.0.1:4318

The Ruby exporter speaks HTTP with protobuf and needs no protocol setting.

Start the server with bin/rails server and open one page.

Signal State
Traces Every request, with the controller, the view, and each SQL statement.
Metrics Only what you record yourself. The Ruby metrics SDK is young.
Logs Not from these gems. Send the Rails log through a branch collector. See Docker branch example.
Terminal window
OTEL_RESOURCE_ATTRIBUTES=deployment.environment.name=staging

See Workspaces and environments.

  1. Open Traces in Loggerhead and click a request to open its waterfall.
  2. Connect your coding agent once, and it reads the same data. See Claude Code.