ryerraguntla commented on code in PR #3516:
URL: https://github.com/apache/iggy/pull/3516#discussion_r3448993108


##########
core/connectors/sources/otlp_source/src/server.rs:
##########
@@ -0,0 +1,141 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::convert;
+use iggy_connector_sdk::ProducedMessage;
+use opentelemetry_proto::tonic::collector::logs::v1::{
+    ExportLogsServiceRequest, ExportLogsServiceResponse,
+    logs_service_server::{LogsService, LogsServiceServer},
+};
+use opentelemetry_proto::tonic::collector::metrics::v1::{
+    ExportMetricsServiceRequest, ExportMetricsServiceResponse,
+    metrics_service_server::{MetricsService, MetricsServiceServer},
+};
+use opentelemetry_proto::tonic::collector::trace::v1::{
+    ExportTraceServiceRequest, ExportTraceServiceResponse,
+    trace_service_server::{TraceService, TraceServiceServer},
+};
+use std::net::SocketAddr;
+use tokio::sync::{mpsc, oneshot};
+use tonic::codec::CompressionEncoding;
+use tonic::{Request, Response, Status};
+use tracing::{error, info, warn};
+
+pub async fn run_grpc_server(
+    addr: SocketAddr,
+    tx: mpsc::Sender<ProducedMessage>,
+    shutdown: oneshot::Receiver<()>,
+) {
+    let logs_svc = LogsServiceImpl { tx: tx.clone() };
+    let metrics_svc = MetricsServiceImpl { tx: tx.clone() };
+    let trace_svc = TraceServiceImpl { tx };
+
+    info!("OTLP gRPC server starting on {addr}");
+
+    // OTel SDKs and the Collector's OTLP exporter gzip-compress payloads by
+    // default, so every service must accept gzip on the wire. Responses are 
tiny
+    // (empty partial_success), but advertising gzip on send is harmless and 
lets
+    // clients negotiate it.
+    let logs_server = LogsServiceServer::new(logs_svc)
+        .accept_compressed(CompressionEncoding::Gzip)
+        .send_compressed(CompressionEncoding::Gzip);
+    let metrics_server = MetricsServiceServer::new(metrics_svc)
+        .accept_compressed(CompressionEncoding::Gzip)
+        .send_compressed(CompressionEncoding::Gzip);
+    let trace_server = TraceServiceServer::new(trace_svc)
+        .accept_compressed(CompressionEncoding::Gzip)
+        .send_compressed(CompressionEncoding::Gzip);
+
+    if let Err(err) = tonic::transport::Server::builder()
+        .add_service(logs_server)
+        .add_service(metrics_server)
+        .add_service(trace_server)
+        .serve_with_shutdown(addr, async {
+            let _ = shutdown.await;
+            info!("OTLP gRPC server received shutdown signal");
+        })
+        .await
+    {
+        error!("OTLP gRPC server error: {err}");
+    }
+}
+
+struct LogsServiceImpl {
+    tx: mpsc::Sender<ProducedMessage>,
+}
+
+struct MetricsServiceImpl {
+    tx: mpsc::Sender<ProducedMessage>,
+}
+
+struct TraceServiceImpl {
+    tx: mpsc::Sender<ProducedMessage>,
+}
+
+#[tonic::async_trait]
+impl LogsService for LogsServiceImpl {
+    async fn export(
+        &self,
+        request: Request<ExportLogsServiceRequest>,
+    ) -> Result<Response<ExportLogsServiceResponse>, Status> {
+        let messages = convert::export_logs_to_messages(request.into_inner());
+        send_messages(&self.tx, messages, "logs").await;

Review Comment:
   Happening in multiple places for each of the OTLP messages - Logs, traces 
and metrics. But commenting in place only with line numbers of other places.
   **97-99, 111-113, 125-127, 137-138** — Channel-full → false SUCCESS: 
try_send at line 137 fails, message dropped, warn! at line 138 fires. All three 
service impls return Ok(Response::new(...{ partial_success: None })) — lines 
97-99 (logs), 111-113 (metrics), 125-127 (traces). OTel SDK sees full 
acceptance, does not retry, does not back off. Data permanently lost with no 
client-visible signal. OTLP gRPC spec requires 
partial_success.rejected_log_records / rejected_spans / rejected_data_points to 
be nonzero when export is rejected. **Fix:** count dropped messages in 
send_messages, return count, populate
   partial_success rejection field in each service impl.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to