Skip to main content

Crate teksilo_analytics_otlp

Crate teksilo_analytics_otlp 

Source
Expand description

teksilo-analytics-otlp — OpenTelemetry-compatible analytics adapter for Teksilo.

Speaks OTLP/HTTP logs over JSON. Works with any OTel-compatible collector — otelcol-contrib, Honeycomb, self-hosted Tempo+Loki via the OTel collector’s HTTP receiver.

§Mapping

Teksilo Event             OTLP LogRecord
──────────────────────── ────────────────────────────────────
event.name               body.stringValue
event.category           attributes["teksilo.category"]
event.timestamp          timeUnixNano (string, OTLP/JSON)
event.install_id         resource.service.instance.id (when set)
event.session_id         attributes["teksilo.session_id"]
event.props.<key>        attributes["teksilo.<key>"]
event.schema_version     attributes["teksilo.schema_version"]

Anonymous-mode batches (no install_id) omit service.instance.id; the OTel collector treats them as aggregate logs.

§Quick start

ⓘ
use teksilo_analytics_otlp::OtlpAdapter;
use std::rc::Rc;

let adapter = Rc::new(
    OtlpAdapter::builder()
        .endpoint("http://127.0.0.1:4318/v1/logs")
        .service_name("my.app")
        .service_version(env!("CARGO_PKG_VERSION"))
        .header("x-honeycomb-team", std::env::var("HONEYCOMB_API_KEY").unwrap())
        .build(),
) as Rc<dyn teksilo_telemetry::UsageReporter>;

§Fetch + erase

Backend-dependent — the OTLP spec has no fetch or delete RPC. The adapter returns TelemetryError::FetchUnsupportedByBackend / ErasureUnsupportedByBackend by default. Operators with a self-hosted Tempo+Loki + an HTTP-side delete API can subclass the adapter (or wait for a future user-provided EraseEndpoint/QueryEndpoint injection point — tracked under future work).

§Queue durability

Unlike teksilo-analytics-plausible and teksilo-analytics-native, this adapter has no built-in persistent queue. Pending events live in an in-memory VecDeque and are lost on hard exit.

This is an intentional design decision, not an oversight:

  1. The OTel deployment model owns durability. OTLP is designed to talk to a collector — typically otelcol or otelcol-contrib running as a sidecar, system service, or on localhost:4318. The collector itself buffers, retries, and persists (via the file_storage extension or its built- in queue). Layering a second durability tier inside the desktop adapter duplicates work the collector already does.
  2. Remote-collector scenarios are atypical for desktop apps. When an app talks straight to a remote OTLP endpoint (e.g. Honeycomb, Grafana Cloud), short network blips are absorbed by the in-memory queue’s retry/backoff loop. Multi-hour offline buffering is not the OTLP HTTP-logs use case.

Operators who need client-side durability against hard exits can fall back to a local collector with a file_storage exporter — the same persistence guarantee the redb-backed adapters provide, but at the right layer of the stack.

If a future use case demands client-side durability (offline laptops with no local collector), exposing OtlpAdapterBuilder::queue(Arc<dyn EventQueue>) matching the Plausible/Teksilo shape is straightforward — the worker already owns the only VecDeque site to swap.

Structs§

OtlpAdapter
OtlpAdapterBuilder
OtlpConfig
Static configuration for the OTLP adapter.