class

Logit::Backend::OTLP::PayloadBuilder

Inherits Reference / Object

Builds OTLP JSON payloads from Logit events.

Converts an array of events to the OTLP/HTTP JSON format for logs. Follows the OpenTelemetry Protocol specification: https://opentelemetry.io/docs/specs/otlp/

Constants

SEVERITY_MAP = {LogLevel::Trace => 1, LogLevel::Debug => 5, LogLevel::Info => 9, LogLevel::Warn => 13, LogLevel::Error => 17, LogLevel::Fatal => 21}

Maps Logit LogLevel to OTLP SeverityNumber. https://opentelemetry.io/docs/specs/otel/logs/data-model/#field-severitynumber

Constructors

new(resource_attributes : Hash(String, String), scope_name : String, scope_version : String)
Source

Instance methods

build(events : Array(Event)) : String

Builds an OTLP JSON payload from an array of events.

Returns a JSON string ready to be sent to an OTLP collector.

Source