Warning
Deprecation Notice: The Coralogix Ruby SDK (coralogix_logger) will be deprecated in favor of the OpenTelemetry SDK and will no longer be supported after June 30, 2026. See the end-of-life notice for migration details.
Ruby
This guide shows how to send logs from Ruby to Coralogix using the OpenTelemetry Ruby logs SDK and the OTLP logs exporter. The Ruby OTLP logs exporter sends HTTP/protobuf. Set OTEL_EXPORTER_OTLP_ENDPOINT to the base URL only (for example http://localhost:4318 when your OpenTelemetry Collector listens for OTLP HTTP on port 4318). The exporter appends the OTLP logs path.
Use Ruby 3.3+ with current opentelemetry-logs-sdk releases. This flow replaces the legacy coralogix_logger gem for log export over OTLP.
Package dependencies setup
Create a Gemfile with the OpenTelemetry logs SDK, OTLP logs exporter, core SDK, and semantic conventions (pin versions to match your environment):
# frozen_string_literal: true
source "https://rubygems.org"
gem "opentelemetry-logs-sdk", "0.5.1"
gem "opentelemetry-exporter-otlp-logs", "0.4.0"
gem "opentelemetry-sdk", "~> 1.3"
gem "opentelemetry-semantic_conventions"
Run the following to install dependencies:
Select the https://ingress. endpoint that corresponds to your Coralogix domain using the domain selector at the top of the page.
Application implementation
Create a LoggerProvider with a Resource, add a BatchLogRecordProcessor backed by OpenTelemetry::Exporter::OTLP::Logs::LogsExporter, emit records with on_emit, then force_flush and shutdown.
The following example defaults OTEL_EXPORTER_OTLP_ENDPOINT to http://localhost:4318 for a typical local collector OTLP HTTP port. Adjust for Coralogix or your collector’s documented URL.
# frozen_string_literal: true
require "opentelemetry/sdk"
require "opentelemetry-logs-sdk"
require "opentelemetry/exporter/otlp_logs"
require "opentelemetry/semantic_conventions/resource"
endpoint = ENV.fetch("OTEL_EXPORTER_OTLP_ENDPOINT", "http://localhost:4318")
resource = OpenTelemetry::SDK::Resources::Resource.create(
{
OpenTelemetry::SemanticConventions::Resource::SERVICE_NAME => ENV.fetch("OTEL_SERVICE_NAME", "ruby-otel-logs-sample"),
"cx.application.name" => ENV.fetch("CORALOGIX_APPLICATION", "ruby-otel-app"),
"cx.subsystem.name" => ENV.fetch("CORALOGIX_SUBSYSTEM", "worker")
}
)
logger_provider = OpenTelemetry::SDK::Logs::LoggerProvider.new(resource: resource)
processor = OpenTelemetry::SDK::Logs::Export::BatchLogRecordProcessor.new(
OpenTelemetry::Exporter::OTLP::Logs::LogsExporter.new(endpoint: endpoint)
)
logger_provider.add_log_record_processor(processor)
otel_logger = logger_provider.logger(name: "ruby-otel-example", version: "1.0.0")
otel_logger.on_emit(
timestamp: Time.now.utc,
severity_text: "INFO",
body: "hello ruby with OpenTelemetry",
attributes: { "application" => ENV.fetch("CORALOGIX_APPLICATION", "ruby-otel-app") }
)
otel_logger.on_emit(
timestamp: Time.now.utc,
severity_text: "WARN",
body: "second log line for batch export",
attributes: { "subsystem" => ENV.fetch("CORALOGIX_SUBSYSTEM", "worker") }
)
sleep 1.5
logger_provider.force_flush
logger_provider.shutdown
puts "Done: flush + shutdown completed"
Run the sample:
Logging output
With the OpenTelemetry SDK, you can send logs either to a local OpenTelemetry Collector or directly to Coralogix using an OTLP endpoint.
OpenTelemetry Collector
Set OTEL_EXPORTER_OTLP_ENDPOINT to the collector’s OTLP HTTP base URL (for example http://localhost:4318 when the collector listens for OTLP HTTP on that port).
Coralogix OpenTelemetry endpoint
Use your Coralogix OTLP endpoint and Send-Your-Data API key. Pass the HTTPS base URL the Ruby OTLP logs exporter expects (see Coralogix Endpoints and your account’s OTLP HTTP settings).
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingress.:443
OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer send_your_data_key"
OTEL_RESOURCE_ATTRIBUTES="service.name=ruby-otel-logs-sample,cx.application.name=AppName,cx.subsystem.name=SubName"
Additional resources
| OpenTelemetry Ruby | OpenTelemetry Ruby docs |
| Coralogix Endpoints | Coralogix Endpoints |
Support
For help, use in-app chat or email [email protected].

