Skip to main content
This page covers instrumenting a Ruby application with the OpenTelemetry SDK to send logs and traces to Bronto over OTLP/HTTP via a local OTel Collector.
If you don’t have a Collector and want to export directly from your application to Bronto, see Direct export to Bronto at the bottom of this page.

Prerequisites

Install dependencies

Gemfile
gem 'opentelemetry-api'
gem 'opentelemetry-sdk'
gem 'opentelemetry-logs-api'
gem 'opentelemetry-logs-sdk'
gem 'opentelemetry-exporter-otlp-logs'
bundle install
GemPurpose
opentelemetry-apiCore OTel API
opentelemetry-sdkSDK — resource configuration
opentelemetry-logs-apiLogs API
opentelemetry-logs-sdkLoggerProvider, processors
opentelemetry-exporter-otlp-logsOTLP/HTTP log exporter

Configure the log bridge

Set up a LoggerProvider with an OTLP exporter and register it as the global logs provider.
configure_logging.rb
require 'opentelemetry/sdk'
require 'opentelemetry/logs/sdk'
require 'opentelemetry-exporter-otlp-logs'

def configure_otel_logging
  resource = OpenTelemetry::SDK::Resources::Resource.create(
    'service.name'           => 'my-service',
    'service.namespace'      => 'my-team',
    'deployment.environment' => 'production'
  )

  exporter = OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new(
    endpoint: 'http://localhost:4318/v1/logs'
  )

  processor = OpenTelemetry::SDK::Logs::Export::BatchLogRecordProcessor.new(exporter)

  logger_provider = OpenTelemetry::SDK::Logs::LoggerProvider.new(resource: resource)
  logger_provider.add_log_record_processor(processor)

  OpenTelemetry::Logs.logger_provider = logger_provider
end
Call configure_otel_logging once at application startup, before the first log statement.

Configure the OTLP exporter

The OtlpLogs::LogsExporter in the snippet above connects to the OTel Collector on localhost:4318. If your Collector runs on a different host or port, update the endpoint accordingly.

Set resource attributes

Resource attributes are attached to every log record exported from this process. Two attributes drive how Bronto organises incoming logs:
OTel attributeBronto conceptDescription
service.nameDatasetGroups logs from one service
service.namespaceCollectionGroups related services or a team’s services
These are set via Resource.create in the setup above.

Complete example

app.rb
require_relative 'configure_logging'

configure_otel_logging

# Emit log records through the OTel logs API directly
logger = OpenTelemetry::Logs.logger_provider.logger(name: 'my-service')

logger.on_emit(
  timestamp: Time.now,
  severity_number: OpenTelemetry::Logs::SeverityNumber::INFO,
  severity_text: 'INFO',
  body: 'Application started'
)

logger.on_emit(
  timestamp: Time.now,
  severity_number: OpenTelemetry::Logs::SeverityNumber::WARN,
  severity_text: 'WARN',
  body: 'Low disk space',
  attributes: { 'disk_free_gb' => 2.1 }
)
A direct bridge to Ruby’s standard Logger class is not yet available in the official SDK. The example above emits log records via the OTel Logs API directly. Community bridges for popular frameworks (Rails, Sidekiq) are in development.

Verify log collection

After running your application, open the Search page in Bronto. Filter by the dataset name you set in service.name — your log records should appear within a few seconds. If no logs appear, check:
  • The OTel Collector is running and reachable at the configured endpoint.
  • The Collector’s pipeline includes a logs pipeline with an otlp receiver and the Bronto exporter — see Connect Open Telemetry to Bronto.
  • configure_otel_logging is called before the first log emission.

Traces

Add opentelemetry-instrumentation-all to your Gemfile and call c.use_all inside OpenTelemetry::SDK.configure to auto-instrument Rails, Rack, Active Record, Faraday, Redis, and more with no code changes. See Ruby instrumentation libraries for the full list.

Install tracing dependencies

Add the tracing gems to your Gemfile:
Gemfile
gem 'opentelemetry-sdk'
gem 'opentelemetry-exporter-otlp'
bundle install

Configure the tracer provider

The opentelemetry-sdk gem covers both logs and traces. Configure tracing via OpenTelemetry::SDK.configure:
configure_tracing.rb
require 'opentelemetry/sdk'
require 'opentelemetry-exporter-otlp'

OpenTelemetry::SDK.configure do |c|
  c.resource = OpenTelemetry::SDK::Resources::Resource.create(
    'service.name'           => 'my-service',
    'service.namespace'      => 'my-team',
    'deployment.environment' => 'production'
  )
  c.add_span_processor(
    OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
      OpenTelemetry::Exporter::OTLP::Exporter.new(
        endpoint: 'http://localhost:4318/v1/traces'
      )
    )
  )
end

Creating spans

tracer = OpenTelemetry.tracer_provider.tracer('my-service')

tracer.in_span('process-payment') do |span|
  span.set_attribute('payment.amount', 99.99)
  span.set_attribute('payment.currency', 'USD')
  # your code here
end

Direct export to Bronto

If you are not using an OTel Collector, export directly to Bronto by replacing the exporter configurations with the Bronto OTLP endpoints and your API key:
# Logs
log_exporter = OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new(
  endpoint: 'https://ingestion.eu.bronto.io/v1/logs', # or ingestion.us.bronto.io
  headers: { 'x-bronto-api-key' => '<YOUR_API_KEY>' }
)

# Traces (inside OpenTelemetry::SDK.configure block)
c.add_span_processor(
  OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
    OpenTelemetry::Exporter::OTLP::Exporter.new(
      endpoint: 'https://ingestion.eu.bronto.io/v1/traces', # or ingestion.us.bronto.io
      headers: { 'x-bronto-api-key' => '<YOUR_API_KEY>' }
    )
  )
)
RegionLogs endpointTraces endpoint
EUhttps://ingestion.eu.bronto.io/v1/logshttps://ingestion.eu.bronto.io/v1/traces
UShttps://ingestion.us.bronto.io/v1/logshttps://ingestion.us.bronto.io/v1/traces
See API Keys for how to create a key with ingestion permissions. No other changes to the rest of the setup are required.