kezhenxu94 commented on code in PR #206:
URL: https://github.com/apache/skywalking-java/pull/206#discussion_r897950747


##########
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/LogReportServiceClient.java:
##########
@@ -95,39 +94,46 @@ public void consume(final List<LogData> dataList) {
             StreamObserver<LogData> logDataStreamObserver = 
logReportServiceStub
                 .withDeadlineAfter(Collector.GRPC_UPSTREAM_TIMEOUT, 
TimeUnit.SECONDS)
                 .collect(
-                new StreamObserver<Commands>() {
-                    @Override
-                    public void onNext(final Commands commands) {
-
-                    }
-
-                    @Override
-                    public void onError(final Throwable throwable) {
-                        status.finished();
-                        LOGGER.error(throwable, "Try to send {} log data to 
collector, with unexpected exception.",
-                                     dataList.size()
-                        );
-                        ServiceManager.INSTANCE
-                            .findService(GRPCChannelManager.class)
-                            .reportError(throwable);
-                    }
-
-                    @Override
-                    public void onCompleted() {
-                        status.finished();
-                    }
-                });
-
-            for (final LogData logData : dataList) {
-                logDataStreamObserver.onNext(logData);
+                    new StreamObserver<Commands>() {
+                        @Override
+                        public void onNext(final Commands commands) {
+
+                        }
+
+                        @Override
+                        public void onError(final Throwable throwable) {
+                            status.finished();
+                            LOGGER.error(throwable, "Try to send {} log data 
to collector, with unexpected exception.",
+                                         dataList.size()
+                            );
+                            ServiceManager.INSTANCE
+                                .findService(GRPCChannelManager.class)
+                                .reportError(throwable);
+                        }
+
+                        @Override
+                        public void onCompleted() {
+                            status.finished();
+                        }
+                    });
+
+            boolean isFirst = true;
+            for (final LogData.Builder logData : dataList) {
+                if (isFirst) {
+                    // Only set service name of the first element in one stream
+                    // 
https://github.com/apache/skywalking-data-collect-protocol/blob/master/logging/Logging.proto
+                    // Log collecting protocol defines LogData#service is 
required in the first element only.
+                    logData.setService(Config.Agent.SERVICE_NAME);

Review Comment:
   ```suggestion
                       logData.setService(Config.Agent.SERVICE_NAME);
                       isFirst = false;
   ```



-- 
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: notifications-unsubscr...@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to