Start the OTLP/HTTP receiver on its dedicated port. Spawns an independent axum server. Call from main after SharedState is created.
(config: OtelConfig, shared: Arc<SharedState>)
| 47 | /// |
| 48 | /// Spawns an independent axum server. Call from main after SharedState is created. |
| 49 | pub async fn run(config: OtelConfig, shared: Arc<SharedState>) -> std::io::Result<()> { |
| 50 | if !config.enabled { |
| 51 | return Ok(()); |
| 52 | } |
| 53 | |
| 54 | let router = Router::new() |
| 55 | .route("/v1/metrics", post(receive_metrics)) |
| 56 | .route("/v1/traces", post(receive_traces)) |
| 57 | .route("/v1/logs", post(receive_logs)) |
| 58 | .with_state(shared); |
| 59 | |
| 60 | let listener = tokio::net::TcpListener::bind(config.listen).await?; |
| 61 | info!(addr = %config.listen, "OTLP/HTTP receiver started"); |
| 62 | axum::serve(listener, router) |
| 63 | .await |
| 64 | .map_err(std::io::Error::other) |
| 65 | } |
| 66 | |
| 67 | /// POST `/v1/metrics` — OTLP metrics receiver. |
| 68 | /// |