Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fintegrations%2Fsdks%2Fruby.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fintegrations%2Fsdks%2Fruby.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

Warning

**Deprecation Notice**: The Coralogix Ruby SDK (`coralogix_logger`) will be deprecated in favor of the [OpenTelemetry SDK](https://opentelemetry.io/docs/languages/ruby/) and will no longer be supported after **June 30, 2026**. See the [end-of-life notice](https://docs-docusaurus.kinsta.page/user-guides/latest-updates/deprecations/ruby-logger-sdk/.md) for migration details.

# Ruby

This guide shows how to send logs from Ruby to Coralogix using the [OpenTelemetry Ruby](https://opentelemetry.io/docs/languages/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[​](#package-dependencies-setup "Direct link to 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:

```
bundle install
```

Select the <!-- -->https\://ingress. endpoint that corresponds to your Coralogix [domain](https://docs-docusaurus.kinsta.page/user-guides/account-management/account-settings/coralogix-domain/.md) using the domain selector at the top of the page.

## Application implementation[​](#application-implementation "Direct link to 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:

```
bundle exec ruby main.rb
```

### Logging output[​](#logging-output "Direct link to Logging output")

With the OpenTelemetry SDK, you can send logs either to a local [OpenTelemetry Collector](https://docs-docusaurus.kinsta.page/opentelemetry/kubernetes-observability/kubernetes-observability-using-opentelemetry/.md) or directly to Coralogix using an OTLP endpoint.

#### OpenTelemetry Collector[​](#opentelemetry-collector "Direct link to 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).

[![](/assets/images/otel_screenshot-65a78a7a0ed6a170f53a63fb1de872f9.webp)](https://docs-docusaurus.kinsta.page/assets/images/otel_screenshot-65a78a7a0ed6a170f53a63fb1de872f9.webp)

#### Coralogix OpenTelemetry endpoint[​](#coralogix-opentelemetry-endpoint "Direct link to Coralogix OpenTelemetry endpoint")

Use your Coralogix OTLP endpoint and [Send-Your-Data API key](https://docs-docusaurus.kinsta.page/user-guides/account-management/api-keys/send-your-data-api-key/.md). Pass the HTTPS base URL the Ruby OTLP logs exporter expects (see [Coralogix Endpoints](https://docs-docusaurus.kinsta.page/integrations/coralogix-endpoints/.md) and your account’s OTLP HTTP settings).

```
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingress.eu2.coralogix.com: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"
```

[![](/assets/images/coralogix_screenshot-16ba770232e1cb47f893d922b7870c90.webp)](https://docs-docusaurus.kinsta.page/assets/images/coralogix_screenshot-16ba770232e1cb47f893d922b7870c90.webp)

### Additional resources[​](#additional-resources "Direct link to Additional resources")

|                     |                                                                                                 |
| ------------------- | ----------------------------------------------------------------------------------------------- |
| OpenTelemetry Ruby  | [OpenTelemetry Ruby docs](https://opentelemetry.io/docs/languages/ruby/)                        |
| Coralogix Endpoints | [Coralogix Endpoints](https://docs-docusaurus.kinsta.page/integrations/coralogix-endpoints/.md) |
