Skip to main content

otel_common/
config.rs

1//! Configuration for OpenTelemetry components.
2
3use serde::{Deserialize, Serialize};
4
5use kinetic_doc_derive::ComponentDoc;
6
7/// OpenTelemetry server (receiver) configuration.
8///
9/// Configures the gRPC and HTTP endpoints for receiving OTLP data.
10#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ComponentDoc)]
11#[component(type = "source", name = "opentelemetry")]
12pub struct OtelServerConfig {
13    /// gRPC endpoint address for OTLP/gRPC (e.g., "0.0.0.0:4317").
14    #[serde(default = "default_grpc_addr")]
15    pub grpc_endpoint: String,
16
17    /// HTTP endpoint address for OTLP/HTTP (e.g., "0.0.0.0:4318").
18    #[serde(default = "default_http_addr")]
19    pub http_endpoint: String,
20}
21
22/// OpenTelemetry client (exporter) configuration.
23///
24/// Configures the endpoint and headers for sending OTLP data.
25#[derive(Debug, Clone, Deserialize, Serialize)]
26pub struct OtelClientConfig {
27    /// Target endpoint URL for OTLP data.
28    pub endpoint: String,
29
30    /// Additional headers to include in OTLP requests.
31    #[serde(default)]
32    pub headers: std::collections::HashMap<String, String>,
33}
34
35fn default_grpc_addr() -> String {
36    "0.0.0.0:4317".to_string()
37}
38
39fn default_http_addr() -> String {
40    "0.0.0.0:4318".to_string()
41}