You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/01/17 03:24:50 UTC
[GitHub] [skywalking] kezhenxu94 commented on a change in pull request #6194: Collect Log with java agent (#6127)
kezhenxu94 commented on a change in pull request #6194:
URL: https://github.com/apache/skywalking/pull/6194#discussion_r559070220
##########
File path: apm-sniffer/apm-toolkit-activation/apm-toolkit-common/pom.xml
##########
@@ -0,0 +1,102 @@
+<!--
+ ~ 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.
+ ~
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>apm-toolkit-activation</artifactId>
+ <groupId>org.apache.skywalking</groupId>
+ <version>8.4.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>apm-toolkit-common</artifactId>
Review comment:
This name is too generic, consider renaming to `apm-toolkit-logging-common`
##########
File path: apm-sniffer/apm-toolkit-activation/apm-toolkit-common/src/main/java/org/apache/skywalking/apm/toolkit/common/log/GRPCLogReportServiceClient.java
##########
@@ -0,0 +1,140 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.skywalking.apm.toolkit.common.log;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.skywalking.apm.agent.core.boot.OverrideImplementor;
+import org.apache.skywalking.apm.agent.core.conf.Config;
+import org.apache.skywalking.apm.agent.core.logging.api.ILog;
+import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
+import org.apache.skywalking.apm.agent.core.remote.GRPCStreamServiceStatus;
+import org.apache.skywalking.apm.agent.core.remote.LogReportServiceClient;
+import org.apache.skywalking.apm.agent.core.util.CollectionUtil;
+import org.apache.skywalking.apm.commons.datacarrier.DataCarrier;
+import org.apache.skywalking.apm.commons.datacarrier.buffer.BufferStrategy;
+import org.apache.skywalking.apm.network.common.v3.Commands;
+import org.apache.skywalking.apm.network.logging.v3.LogData;
+import org.apache.skywalking.apm.network.logging.v3.LogReportServiceGrpc;
+
+import io.grpc.ManagedChannel;
+import io.grpc.ManagedChannelBuilder;
+import io.grpc.StatusRuntimeException;
+import io.grpc.stub.StreamObserver;
+
+/**
+ * Report log to server by grpc
+ */
+@OverrideImplementor(LogReportServiceClient.class)
+public class GRPCLogReportServiceClient extends LogReportServiceClient {
+
+ private static final ILog LOGGER = LogManager.getLogger(GRPCLogReportServiceClient.class);
+
+ private volatile DataCarrier<LogData> carrier;
+
+ private LogReportServiceGrpc.LogReportServiceStub asyncStub;
+
+ private ManagedChannel channel;
+
+ private AtomicBoolean disconnected = new AtomicBoolean(false);
+
+ @Override
+ public void boot() throws Throwable {
+ carrier = new DataCarrier<>("gRPC-log", "gRPC-log", Config.Buffer.CHANNEL_SIZE, Config.Buffer.BUFFER_SIZE,
+ BufferStrategy.IF_POSSIBLE);
+ carrier.consume(this, 1);
+ channel = ManagedChannelBuilder
+ .forAddress(GRPCLogConfig.Plugin.GRPCLog.SERVER_HOST, GRPCLogConfig.Plugin.GRPCLog.SERVER_PORT)
+ .usePlaintext().build();
+ asyncStub = LogReportServiceGrpc.newStub(channel)
+ .withMaxOutboundMessageSize(GRPCLogConfig.Plugin.GRPCLog.MAX_MESSAGE_SIZE);
+ }
+
+ @Override
+ public void shutdown() {
+ try {
+ if (channel != null) {
+ channel.shutdownNow();
+ }
+ carrier.shutdownConsumers();
+ } catch (Throwable t) {
+ LOGGER.error(t.getMessage(), t);
+ }
+ }
+
+ @Override
+ public void produce(LogData logData) {
+ if (Objects.nonNull(logData) && !carrier.produce(logData)) {
+ LOGGER.warn("LogReportServiceClient discard logData: " + logData.toString());
Review comment:
Format the indents
##########
File path: docs/en/setup/service-agent/java-agent/README.md
##########
@@ -159,6 +159,10 @@ property key | Description | Default |
`plugin.kafka.topic_profilings` | Specify which Kafka topic name for Thread Profiling snapshot to report to. | `skywalking_profilings` |
`plugin.kafka.topic_management` | Specify which Kafka topic name for the register or heartbeat data of Service Instance to report to. | `skywalking_managements` |
`plugin.springannotation.classname_match_regex` | Match spring beans with regular expression for the class name. Multiple expressions could be separated by a comma. This only works when `Spring annotation plugin` has been activated. | `All the spring beans tagged with @Bean,@Service,@Dao, or @Repository.` |
+`plugin.grpclog.service_host` | Specify which grpc server's host for log data to report to. | `127.0.0.1` |
+`plugin.grpclog.service_port` | Specify which grpc server's port for traces data to report to. | `8000` |
+`plugin.grpclog.max_message_size` | Specify the maximum size of log data for grpc client to report to. | `10MB` |
Review comment:
The default value `10MB` misleads users that they can set it to something like `20MB`, please use `10485760`
##########
File path: docs/en/setup/service-agent/java-agent/README.md
##########
@@ -159,6 +159,10 @@ property key | Description | Default |
`plugin.kafka.topic_profilings` | Specify which Kafka topic name for Thread Profiling snapshot to report to. | `skywalking_profilings` |
`plugin.kafka.topic_management` | Specify which Kafka topic name for the register or heartbeat data of Service Instance to report to. | `skywalking_managements` |
`plugin.springannotation.classname_match_regex` | Match spring beans with regular expression for the class name. Multiple expressions could be separated by a comma. This only works when `Spring annotation plugin` has been activated. | `All the spring beans tagged with @Bean,@Service,@Dao, or @Repository.` |
+`plugin.grpclog.service_host` | Specify which grpc server's host for log data to report to. | `127.0.0.1` |
+`plugin.grpclog.service_port` | Specify which grpc server's port for traces data to report to. | `8000` |
Review comment:
```suggestion
`plugin.grpclog.service_port` | Specify which grpc server's port for log data to report to. | `8000` |
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org