Class: Snails::Logger::OTLPTransport

Inherits:
Object
  • Object
show all
Defined in:
runtime/snails/logger/otlp_transport.rbs,
runtime/snails/logger/otlp_transport.rb

Defined Under Namespace

Classes: DeliveryError

Constant Summary collapse

OPEN_TIMEOUT =

Timeouts keep a dead endpoint from holding a worker for long.

2
READ_TIMEOUT =

Returns:

2
MAX_ATTEMPTS =

One retry covers a transient 5xx or a dropped connection; a 4xx is permanent (bad token, malformed batch, too large) and is not retried.

2

Instance Method Summary collapse

Constructor Details

#initialize(endpoint:, token:) ⇒ OTLPTransport

configure the destination. The endpoint is the receiver's base URL (scheme, host, and optional path prefix); the transport appends the OTLP logs path itself. A trailing slash on the base is absorbed. The token is sent as Authorization: Bearer. Both are validated here so a typo fails at boot rather than on the first batch.

Parameters:

  • endpoint (String) —

    the base http or https URL

  • token (String) —

    the ingest token

Raises:

  • (ArgumentError) —

    endpoint or token is empty or malformed



55
# File 'runtime/snails/logger/otlp_transport.rb', line 55

def initialize: (endpoint: String, token: String) -> void

Instance Method Details

#after_fork ⇒ void

drop the parent's HTTP session in a forked child. The socket and the lock belong to the parent process; a child that inherited them would write on a connection another process owns.



83
# File 'runtime/snails/logger/otlp_transport.rb', line 83

def after_fork: () -> void

#deliver(records) ⇒ void

encode one batch and enqueue the delivery job. It never performs HTTP; the transport contract stays the hand-off point.

A process without a registered executor would run the job at the call site and block the caller, so that case is refused. The first refusal is reported to the logger; later batches stay local without repeating the warning.

Parameters:

Raises:

  • (RuntimeError) —

    no executor is registered, on the first batch



99
# File 'runtime/snails/logger/otlp_transport.rb', line 99

def deliver: (Array[Record] records) -> void

#send_encoded(body) ⇒ Boolean

post one encoded OTLP batch. A 2xx succeeds; a 4xx raises immediately; a 5xx or a network error is retried once.

Parameters:

  • body (Hash) —

    the OTLP logs JSON structure

Returns:

  • (Boolean) —

    true when the endpoint answered 2xx

Raises:

  • (DeliveryError) —

    the endpoint refused the batch, or the retry budget was spent



120
# File 'runtime/snails/logger/otlp_transport.rb', line 120

def send_encoded: (untyped body) -> bool