Skip to main content

laminar_connectors/otel/
mod.rs

1//! OpenTelemetry (OTLP/gRPC) source connector.
2//!
3//! Receives trace spans, metrics, or logs from OTel exporters and
4//! collectors via the standard OTLP/gRPC protocol. Each source handles
5//! one signal type on its own port.
6//!
7//! ```sql
8//! CREATE SOURCE traces FROM OTEL (port = '4317', signals = 'traces');
9//! CREATE SOURCE metrics FROM OTEL (port = '4318', signals = 'metrics');
10//! CREATE SOURCE logs FROM OTEL (port = '4319', signals = 'logs');
11//! ```
12
13#![allow(clippy::doc_markdown)] // "OTel" is a proper name, not code
14
15pub mod config;
16pub mod convert;
17pub mod schema;
18pub mod server;
19pub mod source;
20
21pub use config::{OtelSignal, OtelSourceConfig};
22pub use source::OtelSource;
23
24use std::sync::Arc;
25
26use crate::config::ConnectorInfo;
27use crate::registry::ConnectorRegistry;
28
29use self::config::otel_source_config_keys;
30use self::schema::traces_schema;
31
32/// Registers the OTel source connector with the given registry.
33///
34/// After registration, the runtime can instantiate `OtelSource` by
35/// name when processing `CREATE SOURCE ... FROM OTEL (...)`.
36pub fn register_otel_source(registry: &ConnectorRegistry) {
37    let info = ConnectorInfo {
38        name: "otel".to_string(),
39        display_name: "OpenTelemetry OTLP/gRPC Source".to_string(),
40        version: env!("CARGO_PKG_VERSION").to_string(),
41        is_source: true,
42        is_sink: false,
43        config_keys: otel_source_config_keys(),
44    };
45
46    registry.register_source(
47        "otel",
48        info,
49        Arc::new(|registry: Option<&prometheus::Registry>| {
50            Box::new(OtelSource::new(traces_schema(), registry))
51        }),
52    );
53}