Skip to main content

Crate rlg_otlp

Crate rlg_otlp 

Source
Expand description

OpenTelemetry (OTLP) network exporter for rlg.

rlg renders records in LogFormat::OTLP shape and writes them to the configured PlatformSink (stdout, file, os_log, journald). This crate adds an HTTP exporter that POSTs OTLP-shaped records to an OpenTelemetry Collector.

Wire format: OTLP/HTTP JSON encoding (Content-Type: application/json), over plain http://.

§Deployment: a local collector owns TLS

The exporter carries no TLS stack. It sends to a Collector (or any OTLP/HTTP forwarder) on the same host or pod, by default DEFAULT_ENDPOINT, and the Collector holds the TLS connection and credentials for the backend. https:// endpoints are refused. The README has a minimal Collector configuration.

§Example

use rlg_otlp::OtlpExporter;
use rlg::log::Log;
use rlg::log_format::LogFormat;

// Defaults to the Collector at http://localhost:4318/v1/logs.
let exporter = OtlpExporter::builder().timeout_secs(10).build();

let record = Log::error("payment-service down")
    .component("orders")
    .with("trace_id", "abc")
    .format(LogFormat::OTLP);

// Synchronous push. Async push is on the roadmap.
exporter.export_one(&record).unwrap();

Re-exports§

pub use crate::backoff::CircuitBreaker;
pub use crate::backoff::RetryPolicy;
pub use crate::async_http::AsyncOtlpExporter;async
pub use crate::async_http::AsyncOtlpExporterBuilder;async

Modules§

async_httpasync
Async HTTP/JSON transport over Tokio and plain http://. Enable with the async feature. Async HTTP transport for OTLP/JSON over plain http://.
backoff
Retry policy + full-jitter + tokens-per-window circuit breaker.

Structs§

OtlpExporter
Synchronous HTTP/JSON exporter to an OTLP-compatible collector.
OtlpExporterBuilder
Fluent builder for OtlpExporter.

Enums§

OtlpError
Errors raised by OtlpExporter.

Constants§

DEFAULT_ENDPOINT
The endpoint a builder uses when given none: the OTLP/HTTP logs route of a Collector on the same host.

Functions§

serialise_batch
Serialise a batch of records into a single OTLP/HTTP JSON envelope.

Type Aliases§

OtlpResult
A Result alias with OtlpError as the error variant.