You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/03/01 10:50:29 UTC

[GitHub] [incubator-inlong] baomingyu opened a new pull request #2806: [INLONG-][dataproxy]add stream config log report feature

baomingyu opened a new pull request #2806:
URL: https://github.com/apache/incubator-inlong/pull/2806


   add stream config log report feature
   
   Fixes #2805


-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] baomingyu commented on a change in pull request #2806: [INLONG-2805][DataProxy] Add stream config log report

Posted by GitBox <gi...@apache.org>.
baomingyu commented on a change in pull request #2806:
URL: https://github.com/apache/incubator-inlong/pull/2806#discussion_r817411531



##########
File path: inlong-common/src/main/java/org/apache/inlong/common/reporpter/ConfigLogTypeEnum.java
##########
@@ -15,32 +15,33 @@
  * limitations under the License.
  */
 
-package org.apache.inlong.common.reporpter.dto;
+package org.apache.inlong.common.reporpter;
 
-import java.util.Date;
-import lombok.Getter;
-import lombok.Setter;
+import static java.util.Objects.requireNonNull;
 
-@Setter
-@Getter
-public class StreamMetricInfo {
+public enum ConfigLogTypeEnum {
 
-    private String ip;
+    NORMAL(0),ERROR(1);

Review comment:
       Will be used later, reserve




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2806: [INLONG-2805][DataProxy] Add stream config log report

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2806:
URL: https://github.com/apache/incubator-inlong/pull/2806#discussion_r817301111



##########
File path: inlong-common/src/main/java/org/apache/inlong/common/reporpter/ConfigLogTypeEnum.java
##########
@@ -15,32 +15,33 @@
  * limitations under the License.
  */
 
-package org.apache.inlong.common.reporpter.dto;
+package org.apache.inlong.common.reporpter;
 
-import java.util.Date;
-import lombok.Getter;
-import lombok.Setter;
+import static java.util.Objects.requireNonNull;
 
-@Setter
-@Getter
-public class StreamMetricInfo {
+public enum ConfigLogTypeEnum {
 
-    private String ip;
+    NORMAL(0),ERROR(1);

Review comment:
       NORMAL have not been used.




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] baomingyu commented on a change in pull request #2806: [INLONG-2805][DataProxy] Add stream config log report

Posted by GitBox <gi...@apache.org>.
baomingyu commented on a change in pull request #2806:
URL: https://github.com/apache/incubator-inlong/pull/2806#discussion_r817668911



##########
File path: inlong-common/src/main/java/org/apache/inlong/common/reporpter/StreamConfigLogMetric.java
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.inlong.common.reporpter;
+
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import java.time.Instant;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.inlong.common.reporpter.dto.StreamConfigLogInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StreamConfigLogMetric implements Runnable {
+
+    public static final Logger LOGGER = LoggerFactory.getLogger(StreamConfigLogMetric.class);
+
+    private StreamConfigLogReporter streamConfigLogReporter;
+
+    private String moduleName;
+
+    private String clientVersion;
+
+    private String localIp;
+
+    private long reportInterval;
+
+    public ConcurrentHashMap<String, StreamConfigLogInfo> dataCacheMap = new ConcurrentHashMap<>();
+
+    private static ScheduledExecutorService statExecutor =
+            Executors.newScheduledThreadPool(2, new ThreadFactoryBuilder()
+                    .setNameFormat("StreamConfigLogMetric-Report")
+                    .setUncaughtExceptionHandler((t, e) ->
+                            LOGGER.error(t.getName() + " has an uncaught exception: ", e))
+                    .build());
+
+    public StreamConfigLogMetric(String moduleName, String serverUrl, long reportInterval,
+            String localIp, String clientVersion) {
+        this.streamConfigLogReporter = new StreamConfigLogReporter(serverUrl);
+        this.reportInterval = reportInterval;
+        this.moduleName = moduleName;
+        this.localIp = localIp;
+        this.clientVersion = clientVersion;
+        statExecutor.scheduleWithFixedDelay(this,
+                reportInterval, reportInterval, TimeUnit.MILLISECONDS);
+    }
+
+    public void updateConfigLog(String inlongGroupId, String inlongStreamId, String configName,
+            ConfigLogTypeEnum configLogTypeEnum, String log) {
+        String key = moduleName + inlongGroupId + inlongStreamId + configName;
+        LOGGER.debug("updateConfigLog key = {}", key);
+        dataCacheMap.compute(key, (k, v) -> {
+            if (v == null) {
+                v = new StreamConfigLogInfo();
+            }
+            updateDataValue(v, inlongGroupId,
+                    inlongStreamId, configName, configLogTypeEnum, log);
+            return v;
+        });
+    }
+
+    private void updateDataValue(StreamConfigLogInfo streamConfigLogInfo,
+            String inlongGroupId, String inlongStreamId, String configName,
+            ConfigLogTypeEnum configLogTypeEnum, String log) {
+        streamConfigLogInfo.setComponentName(moduleName);
+        streamConfigLogInfo.setConfigName(configName);
+        streamConfigLogInfo.setInlongGroupId(inlongGroupId);
+        streamConfigLogInfo.setInlongStreamId(inlongStreamId);
+        streamConfigLogInfo.setIp(localIp);
+        streamConfigLogInfo.setVersion(clientVersion);
+        streamConfigLogInfo.setLogInfo(log);
+        streamConfigLogInfo.setReportTime(Instant.now().toEpochMilli());
+        streamConfigLogInfo.setLogType(configLogTypeEnum.getType());

Review comment:
       count is not needed here. every log need to be reported.




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] aloyszhang commented on a change in pull request #2806: [INLONG-2805][DataProxy] Add stream config log report

Posted by GitBox <gi...@apache.org>.
aloyszhang commented on a change in pull request #2806:
URL: https://github.com/apache/incubator-inlong/pull/2806#discussion_r818626288



##########
File path: inlong-common/src/main/java/org/apache/inlong/common/reporpter/StreamConfigLogMetric.java
##########
@@ -0,0 +1,131 @@
+/*
+ * 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.inlong.common.reporpter;
+
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import java.time.Instant;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.inlong.common.reporpter.dto.StreamConfigLogInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StreamConfigLogMetric implements Runnable {
+
+    public static final Logger LOGGER = LoggerFactory.getLogger(StreamConfigLogMetric.class);
+
+    /*
+     * config name for log report
+     */
+    public static final String CONFIG_LOG_REPORT_ENABLE = "report.config.log.enable";
+    public static final String CONFIG_LOG_REPORT_SERVER_URL = "report.config.log.server.url";
+    public static final String CONFIG_LOG_REPORT_INTERVAL = "report.config.log.interval";
+    public static final String CONFIG_LOG_REPORT_CLIENT_VERSION = "report.config.log.client.version";
+    public static final String CONFIG_LOG_PULSAR_PRODUCER = "pulsar-producer";
+    public static final String CONFIG_LOG_PULSAR_CLIENT = "pulsar-client";
+
+    private StreamConfigLogReporter streamConfigLogReporter;
+
+    private String moduleName;
+
+    private String clientVersion;
+
+    private String localIp;
+
+    private long reportInterval;
+
+    public ConcurrentHashMap<String, StreamConfigLogInfo> dataCacheMap = new ConcurrentHashMap<>();
+
+    private static ScheduledExecutorService statExecutor =
+            Executors.newScheduledThreadPool(2, new ThreadFactoryBuilder()
+                    .setNameFormat("StreamConfigLogMetric-Report")
+                    .setUncaughtExceptionHandler((t, e) ->
+                            LOGGER.error(t.getName() + " has an uncaught exception: ", e))
+                    .build());
+
+    public StreamConfigLogMetric(String moduleName, String serverUrl, long reportInterval,
+            String localIp, String clientVersion) {
+        this.streamConfigLogReporter = new StreamConfigLogReporter(serverUrl);
+        this.reportInterval = reportInterval;
+        this.moduleName = moduleName;
+        this.localIp = localIp;
+        this.clientVersion = clientVersion;
+        statExecutor.scheduleWithFixedDelay(this,
+                reportInterval, reportInterval, TimeUnit.MILLISECONDS);
+    }
+
+    /**
+     * updateConfigLog
+     * @param inlongGroupId  inlongGroupId
+     * @param inlongStreamId inlongStreamId
+     * @param configName configName
+     * @param configLogTypeEnum configLogTypeEnum
+     * @param log log
+     */
+    public void updateConfigLog(String inlongGroupId, String inlongStreamId, String configName,
+            ConfigLogTypeEnum configLogTypeEnum, String log) {
+        String key = moduleName + "-" +  inlongGroupId + "-" + inlongStreamId + "-" + configName;
+        LOGGER.debug("updateConfigLog key = {}", key);

Review comment:
       LOGGER.debug should be covered by LOGGER.isDebugEnabled




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] baomingyu commented on a change in pull request #2806: [INLONG-2805][DataProxy] Add stream config log report

Posted by GitBox <gi...@apache.org>.
baomingyu commented on a change in pull request #2806:
URL: https://github.com/apache/incubator-inlong/pull/2806#discussion_r817663081



##########
File path: inlong-common/src/main/java/org/apache/inlong/common/reporpter/StreamConfigLogMetric.java
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.inlong.common.reporpter;
+
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import java.time.Instant;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.inlong.common.reporpter.dto.StreamConfigLogInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StreamConfigLogMetric implements Runnable {
+
+    public static final Logger LOGGER = LoggerFactory.getLogger(StreamConfigLogMetric.class);
+
+    private StreamConfigLogReporter streamConfigLogReporter;
+
+    private String moduleName;
+
+    private String clientVersion;
+
+    private String localIp;
+
+    private long reportInterval;
+
+    public ConcurrentHashMap<String, StreamConfigLogInfo> dataCacheMap = new ConcurrentHashMap<>();
+
+    private static ScheduledExecutorService statExecutor =
+            Executors.newScheduledThreadPool(2, new ThreadFactoryBuilder()
+                    .setNameFormat("StreamConfigLogMetric-Report")
+                    .setUncaughtExceptionHandler((t, e) ->
+                            LOGGER.error(t.getName() + " has an uncaught exception: ", e))
+                    .build());
+
+    public StreamConfigLogMetric(String moduleName, String serverUrl, long reportInterval,
+            String localIp, String clientVersion) {
+        this.streamConfigLogReporter = new StreamConfigLogReporter(serverUrl);
+        this.reportInterval = reportInterval;
+        this.moduleName = moduleName;
+        this.localIp = localIp;
+        this.clientVersion = clientVersion;
+        statExecutor.scheduleWithFixedDelay(this,
+                reportInterval, reportInterval, TimeUnit.MILLISECONDS);
+    }
+
+    public void updateConfigLog(String inlongGroupId, String inlongStreamId, String configName,
+            ConfigLogTypeEnum configLogTypeEnum, String log) {
+        String key = moduleName + inlongGroupId + inlongStreamId + configName;

Review comment:
       done




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] aloyszhang commented on a change in pull request #2806: [INLONG-2805][DataProxy] Add stream config log report

Posted by GitBox <gi...@apache.org>.
aloyszhang commented on a change in pull request #2806:
URL: https://github.com/apache/incubator-inlong/pull/2806#discussion_r818626424



##########
File path: inlong-common/src/main/java/org/apache/inlong/common/reporpter/StreamConfigLogMetric.java
##########
@@ -0,0 +1,131 @@
+/*
+ * 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.inlong.common.reporpter;
+
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import java.time.Instant;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.inlong.common.reporpter.dto.StreamConfigLogInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StreamConfigLogMetric implements Runnable {
+
+    public static final Logger LOGGER = LoggerFactory.getLogger(StreamConfigLogMetric.class);
+
+    /*
+     * config name for log report
+     */
+    public static final String CONFIG_LOG_REPORT_ENABLE = "report.config.log.enable";
+    public static final String CONFIG_LOG_REPORT_SERVER_URL = "report.config.log.server.url";
+    public static final String CONFIG_LOG_REPORT_INTERVAL = "report.config.log.interval";
+    public static final String CONFIG_LOG_REPORT_CLIENT_VERSION = "report.config.log.client.version";
+    public static final String CONFIG_LOG_PULSAR_PRODUCER = "pulsar-producer";
+    public static final String CONFIG_LOG_PULSAR_CLIENT = "pulsar-client";
+
+    private StreamConfigLogReporter streamConfigLogReporter;
+
+    private String moduleName;
+
+    private String clientVersion;
+
+    private String localIp;
+
+    private long reportInterval;
+
+    public ConcurrentHashMap<String, StreamConfigLogInfo> dataCacheMap = new ConcurrentHashMap<>();
+
+    private static ScheduledExecutorService statExecutor =
+            Executors.newScheduledThreadPool(2, new ThreadFactoryBuilder()
+                    .setNameFormat("StreamConfigLogMetric-Report")
+                    .setUncaughtExceptionHandler((t, e) ->
+                            LOGGER.error(t.getName() + " has an uncaught exception: ", e))
+                    .build());
+
+    public StreamConfigLogMetric(String moduleName, String serverUrl, long reportInterval,
+            String localIp, String clientVersion) {
+        this.streamConfigLogReporter = new StreamConfigLogReporter(serverUrl);
+        this.reportInterval = reportInterval;
+        this.moduleName = moduleName;
+        this.localIp = localIp;
+        this.clientVersion = clientVersion;
+        statExecutor.scheduleWithFixedDelay(this,
+                reportInterval, reportInterval, TimeUnit.MILLISECONDS);
+    }
+
+    /**
+     * updateConfigLog
+     * @param inlongGroupId  inlongGroupId
+     * @param inlongStreamId inlongStreamId
+     * @param configName configName
+     * @param configLogTypeEnum configLogTypeEnum
+     * @param log log
+     */
+    public void updateConfigLog(String inlongGroupId, String inlongStreamId, String configName,
+            ConfigLogTypeEnum configLogTypeEnum, String log) {
+        String key = moduleName + "-" +  inlongGroupId + "-" + inlongStreamId + "-" + configName;
+        LOGGER.debug("updateConfigLog key = {}", key);
+        dataCacheMap.compute(key, (k, v) -> {
+            if (v == null) {
+                v = new StreamConfigLogInfo();
+            }
+            updateDataValue(v, inlongGroupId,
+                    inlongStreamId, configName, configLogTypeEnum, log);
+            return v;
+        });
+    }
+
+    private void updateDataValue(StreamConfigLogInfo streamConfigLogInfo,
+            String inlongGroupId, String inlongStreamId, String configName,
+            ConfigLogTypeEnum configLogTypeEnum, String log) {
+        streamConfigLogInfo.setComponentName(moduleName);
+        streamConfigLogInfo.setConfigName(configName);
+        streamConfigLogInfo.setInlongGroupId(inlongGroupId);
+        streamConfigLogInfo.setInlongStreamId(inlongStreamId);
+        streamConfigLogInfo.setIp(localIp);
+        streamConfigLogInfo.setVersion(clientVersion);
+        streamConfigLogInfo.setLogInfo(log);
+        streamConfigLogInfo.setReportTime(Instant.now().toEpochMilli());
+        streamConfigLogInfo.setLogType(configLogTypeEnum.getType());
+    }
+
+    public void run() {
+        try {
+            LOGGER.debug("Report metric data!");
+            Set<Entry<String, StreamConfigLogInfo>> set = dataCacheMap.entrySet();
+            long currentTimeMills = Instant.now().toEpochMilli();
+            for (Entry<String, StreamConfigLogInfo> entry : set) {
+                StreamConfigLogInfo streamConfigLogInfo = entry.getValue();
+                if ((currentTimeMills - streamConfigLogInfo.getReportTime()) < reportInterval) {
+                    LOGGER.debug("Report metric data config key = {}!", streamConfigLogInfo.getConfigName());

Review comment:
       ditto




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2806: [INLONG-2805][DataProxy] Add stream config log report

Posted by GitBox <gi...@apache.org>.
luchunliang commented on a change in pull request #2806:
URL: https://github.com/apache/incubator-inlong/pull/2806#discussion_r817297029



##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/sink/PulsarSink.java
##########
@@ -221,14 +224,32 @@ public void configure(Context context) {
         topicProperties = configManager.getTopicProperties();
         pulsarCluster = configManager.getThirdPartyClusterUrl2Token();
         pulsarConfig = configManager.getThirdPartyClusterConfig(); //pulsar common config
+        commonProperties = configManager.getCommonProperties();
         pulsarClientService = new PulsarClientService(pulsarConfig);
+        boolean enableReportConfigLog =
+                Boolean.parseBoolean(commonProperties
+                        .getOrDefault(ConfigConstants.CONFIG_LOG_REPORT_ENABLE,"true"));
+        localIp = NetworkUtils.getLocalIp();
+        if (enableReportConfigLog) {
+            String reportConfigServerUrl = commonProperties
+                    .getOrDefault(ConfigConstants.CONFIG_LOG_REPORT_SERVER_URL, "");
+            String reportConfigLogInterval = commonProperties
+                    .getOrDefault(ConfigConstants.CONFIG_LOG_REPORT_INTERVAL, "60000");
+            String clientVersion = commonProperties
+                    .getOrDefault(ConfigConstants.CONFIG_LOG_REPORT_CLIENT_VERSION, "");
+            streamConfigLogMetric = new StreamConfigLogMetric(ConfigConstants.COMPONENT_NAME,
+                    reportConfigServerUrl, Long.parseLong(reportConfigLogInterval),
+                    localIp, clientVersion);

Review comment:
       This metric can be reported in MetricLisenter, exception id can be a sink-data-id.
   For example:
   metricDomains.DataProxy.domainListeners=com.tencent.pcg.atta.dataproxy.metrics.m007.M007MetricListener com.tencent.pcg.atta.dataproxy.metrics.attaaudit.AttaAuditMetricListener

##########
File path: inlong-common/src/main/java/org/apache/inlong/common/reporpter/StreamConfigLogMetric.java
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.inlong.common.reporpter;
+
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import java.time.Instant;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.inlong.common.reporpter.dto.StreamConfigLogInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StreamConfigLogMetric implements Runnable {
+
+    public static final Logger LOGGER = LoggerFactory.getLogger(StreamConfigLogMetric.class);
+
+    private StreamConfigLogReporter streamConfigLogReporter;
+
+    private String moduleName;
+
+    private String clientVersion;
+
+    private String localIp;
+
+    private long reportInterval;
+
+    public ConcurrentHashMap<String, StreamConfigLogInfo> dataCacheMap = new ConcurrentHashMap<>();
+
+    private static ScheduledExecutorService statExecutor =
+            Executors.newScheduledThreadPool(2, new ThreadFactoryBuilder()
+                    .setNameFormat("StreamConfigLogMetric-Report")
+                    .setUncaughtExceptionHandler((t, e) ->
+                            LOGGER.error(t.getName() + " has an uncaught exception: ", e))
+                    .build());
+
+    public StreamConfigLogMetric(String moduleName, String serverUrl, long reportInterval,
+            String localIp, String clientVersion) {
+        this.streamConfigLogReporter = new StreamConfigLogReporter(serverUrl);
+        this.reportInterval = reportInterval;
+        this.moduleName = moduleName;
+        this.localIp = localIp;
+        this.clientVersion = clientVersion;
+        statExecutor.scheduleWithFixedDelay(this,
+                reportInterval, reportInterval, TimeUnit.MILLISECONDS);
+    }
+
+    public void updateConfigLog(String inlongGroupId, String inlongStreamId, String configName,
+            ConfigLogTypeEnum configLogTypeEnum, String log) {
+        String key = moduleName + inlongGroupId + inlongStreamId + configName;

Review comment:
       Two different keys perhaps are same without separator.

##########
File path: inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/openapi/StreamConfigLogController.java
##########
@@ -23,20 +23,22 @@
 import org.apache.inlong.manager.common.pojo.stream.InlongStreamConfigLogRequest;
 import org.apache.inlong.manager.service.core.StreamConfigLogService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 @RestController
-@RequestMapping("/openapi")
+@RequestMapping("/openapi/stream")
 @Api(tags = "Stream Config")
 public class StreamConfigLogController {
 
     @Autowired
     private StreamConfigLogService streamConfigLogService;
 
-    @PostMapping("/stream/log/reportConfigLogStatus")
+    @PostMapping(value = "/log/reportConfigLogStatus",
+            produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
     @ApiOperation(value = "stream config log status")
     public Response<String> reportStreamConfigLogStatus(@RequestBody
             InlongStreamConfigLogRequest info) {

Review comment:
       It is not suggested to save the log to DB, if the inlong datastream is more than 1000 and proxy node is more than 100.

##########
File path: inlong-common/src/main/java/org/apache/inlong/common/reporpter/StreamConfigLogMetric.java
##########
@@ -0,0 +1,113 @@
+/*
+ * 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.inlong.common.reporpter;
+
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import java.time.Instant;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.inlong.common.reporpter.dto.StreamConfigLogInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StreamConfigLogMetric implements Runnable {
+
+    public static final Logger LOGGER = LoggerFactory.getLogger(StreamConfigLogMetric.class);
+
+    private StreamConfigLogReporter streamConfigLogReporter;
+
+    private String moduleName;
+
+    private String clientVersion;
+
+    private String localIp;
+
+    private long reportInterval;
+
+    public ConcurrentHashMap<String, StreamConfigLogInfo> dataCacheMap = new ConcurrentHashMap<>();
+
+    private static ScheduledExecutorService statExecutor =
+            Executors.newScheduledThreadPool(2, new ThreadFactoryBuilder()
+                    .setNameFormat("StreamConfigLogMetric-Report")
+                    .setUncaughtExceptionHandler((t, e) ->
+                            LOGGER.error(t.getName() + " has an uncaught exception: ", e))
+                    .build());
+
+    public StreamConfigLogMetric(String moduleName, String serverUrl, long reportInterval,
+            String localIp, String clientVersion) {
+        this.streamConfigLogReporter = new StreamConfigLogReporter(serverUrl);
+        this.reportInterval = reportInterval;
+        this.moduleName = moduleName;
+        this.localIp = localIp;
+        this.clientVersion = clientVersion;
+        statExecutor.scheduleWithFixedDelay(this,
+                reportInterval, reportInterval, TimeUnit.MILLISECONDS);
+    }
+
+    public void updateConfigLog(String inlongGroupId, String inlongStreamId, String configName,
+            ConfigLogTypeEnum configLogTypeEnum, String log) {
+        String key = moduleName + inlongGroupId + inlongStreamId + configName;
+        LOGGER.debug("updateConfigLog key = {}", key);
+        dataCacheMap.compute(key, (k, v) -> {
+            if (v == null) {
+                v = new StreamConfigLogInfo();
+            }
+            updateDataValue(v, inlongGroupId,
+                    inlongStreamId, configName, configLogTypeEnum, log);
+            return v;
+        });
+    }
+
+    private void updateDataValue(StreamConfigLogInfo streamConfigLogInfo,
+            String inlongGroupId, String inlongStreamId, String configName,
+            ConfigLogTypeEnum configLogTypeEnum, String log) {
+        streamConfigLogInfo.setComponentName(moduleName);
+        streamConfigLogInfo.setConfigName(configName);
+        streamConfigLogInfo.setInlongGroupId(inlongGroupId);
+        streamConfigLogInfo.setInlongStreamId(inlongStreamId);
+        streamConfigLogInfo.setIp(localIp);
+        streamConfigLogInfo.setVersion(clientVersion);
+        streamConfigLogInfo.setLogInfo(log);
+        streamConfigLogInfo.setReportTime(Instant.now().toEpochMilli());
+        streamConfigLogInfo.setLogType(configLogTypeEnum.getType());

Review comment:
       Miss count field.




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] healchow merged pull request #2806: [INLONG-2805][DataProxy] Add stream config log report

Posted by GitBox <gi...@apache.org>.
healchow merged pull request #2806:
URL: https://github.com/apache/incubator-inlong/pull/2806


   


-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] aloyszhang commented on a change in pull request #2806: [INLONG-2805][DataProxy] Add stream config log report

Posted by GitBox <gi...@apache.org>.
aloyszhang commented on a change in pull request #2806:
URL: https://github.com/apache/incubator-inlong/pull/2806#discussion_r818626573



##########
File path: inlong-common/src/main/java/org/apache/inlong/common/reporpter/StreamConfigLogMetric.java
##########
@@ -0,0 +1,131 @@
+/*
+ * 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.inlong.common.reporpter;
+
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import java.time.Instant;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.apache.inlong.common.reporpter.dto.StreamConfigLogInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class StreamConfigLogMetric implements Runnable {
+
+    public static final Logger LOGGER = LoggerFactory.getLogger(StreamConfigLogMetric.class);
+
+    /*
+     * config name for log report
+     */
+    public static final String CONFIG_LOG_REPORT_ENABLE = "report.config.log.enable";
+    public static final String CONFIG_LOG_REPORT_SERVER_URL = "report.config.log.server.url";
+    public static final String CONFIG_LOG_REPORT_INTERVAL = "report.config.log.interval";
+    public static final String CONFIG_LOG_REPORT_CLIENT_VERSION = "report.config.log.client.version";
+    public static final String CONFIG_LOG_PULSAR_PRODUCER = "pulsar-producer";
+    public static final String CONFIG_LOG_PULSAR_CLIENT = "pulsar-client";
+
+    private StreamConfigLogReporter streamConfigLogReporter;
+
+    private String moduleName;
+
+    private String clientVersion;
+
+    private String localIp;
+
+    private long reportInterval;
+
+    public ConcurrentHashMap<String, StreamConfigLogInfo> dataCacheMap = new ConcurrentHashMap<>();
+
+    private static ScheduledExecutorService statExecutor =
+            Executors.newScheduledThreadPool(2, new ThreadFactoryBuilder()
+                    .setNameFormat("StreamConfigLogMetric-Report")
+                    .setUncaughtExceptionHandler((t, e) ->
+                            LOGGER.error(t.getName() + " has an uncaught exception: ", e))
+                    .build());
+
+    public StreamConfigLogMetric(String moduleName, String serverUrl, long reportInterval,
+            String localIp, String clientVersion) {
+        this.streamConfigLogReporter = new StreamConfigLogReporter(serverUrl);
+        this.reportInterval = reportInterval;
+        this.moduleName = moduleName;
+        this.localIp = localIp;
+        this.clientVersion = clientVersion;
+        statExecutor.scheduleWithFixedDelay(this,
+                reportInterval, reportInterval, TimeUnit.MILLISECONDS);
+    }
+
+    /**
+     * updateConfigLog
+     * @param inlongGroupId  inlongGroupId
+     * @param inlongStreamId inlongStreamId
+     * @param configName configName
+     * @param configLogTypeEnum configLogTypeEnum
+     * @param log log
+     */
+    public void updateConfigLog(String inlongGroupId, String inlongStreamId, String configName,
+            ConfigLogTypeEnum configLogTypeEnum, String log) {
+        String key = moduleName + "-" +  inlongGroupId + "-" + inlongStreamId + "-" + configName;
+        LOGGER.debug("updateConfigLog key = {}", key);
+        dataCacheMap.compute(key, (k, v) -> {
+            if (v == null) {
+                v = new StreamConfigLogInfo();
+            }
+            updateDataValue(v, inlongGroupId,
+                    inlongStreamId, configName, configLogTypeEnum, log);
+            return v;
+        });
+    }
+
+    private void updateDataValue(StreamConfigLogInfo streamConfigLogInfo,
+            String inlongGroupId, String inlongStreamId, String configName,
+            ConfigLogTypeEnum configLogTypeEnum, String log) {
+        streamConfigLogInfo.setComponentName(moduleName);
+        streamConfigLogInfo.setConfigName(configName);
+        streamConfigLogInfo.setInlongGroupId(inlongGroupId);
+        streamConfigLogInfo.setInlongStreamId(inlongStreamId);
+        streamConfigLogInfo.setIp(localIp);
+        streamConfigLogInfo.setVersion(clientVersion);
+        streamConfigLogInfo.setLogInfo(log);
+        streamConfigLogInfo.setReportTime(Instant.now().toEpochMilli());
+        streamConfigLogInfo.setLogType(configLogTypeEnum.getType());
+    }
+
+    public void run() {
+        try {
+            LOGGER.debug("Report metric data!");

Review comment:
       ditto




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] aloyszhang commented on a change in pull request #2806: [INLONG-2805][DataProxy] Add stream config log report

Posted by GitBox <gi...@apache.org>.
aloyszhang commented on a change in pull request #2806:
URL: https://github.com/apache/incubator-inlong/pull/2806#discussion_r818625981



##########
File path: inlong-common/src/main/java/org/apache/inlong/common/reporpter/AbstractReporter.java
##########
@@ -96,25 +94,27 @@ public AbstractReporter(CloseableHttpClient httpClient, String serverUrl, int co
         this.httpClient = httpClient;
     }
 
-    public R syncReportData(T data, String serverUrl) throws Exception {
+    public Response syncReportData(T data, String serverUrl) throws Exception {
+        if (StringUtils.isEmpty(serverUrl)) {
+            LOGGER.warn("Report config log server url is empty, so config log can not be "
+                    + "reported!");
+            return null;
+        }
         HttpPost httpPost = new HttpPost(serverUrl);
         try {
             StringEntity stringEntity = new StringEntity(gson.toJson(data));
             stringEntity.setContentType(AGENT_HTTP_APPLICATION_JSON);
             httpPost.setEntity(stringEntity);
             String returnStr = executeHttpPost(httpPost);
-            ResponseType<R> re = parse(returnStr);
-            if (re != null) {
-                return re.getResponse();
-            }
+            LOGGER.debug("Reporter returnStr = {}", returnStr);

Review comment:
       `LOGGER.debug` should be covered by `LOGGER.isDebugEnabled`




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] baomingyu commented on a change in pull request #2806: [INLONG-2805][DataProxy] Add stream config log report

Posted by GitBox <gi...@apache.org>.
baomingyu commented on a change in pull request #2806:
URL: https://github.com/apache/incubator-inlong/pull/2806#discussion_r817666547



##########
File path: inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/openapi/StreamConfigLogController.java
##########
@@ -23,20 +23,22 @@
 import org.apache.inlong.manager.common.pojo.stream.InlongStreamConfigLogRequest;
 import org.apache.inlong.manager.service.core.StreamConfigLogService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 @RestController
-@RequestMapping("/openapi")
+@RequestMapping("/openapi/stream")
 @Api(tags = "Stream Config")
 public class StreamConfigLogController {
 
     @Autowired
     private StreamConfigLogService streamConfigLogService;
 
-    @PostMapping("/stream/log/reportConfigLogStatus")
+    @PostMapping(value = "/log/reportConfigLogStatus",
+            produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
     @ApiOperation(value = "stream config log status")
     public Response<String> reportStreamConfigLogStatus(@RequestBody
             InlongStreamConfigLogRequest info) {

Review comment:
       When there is an error in each configuration item, it will be reported in an updated way, so there will only be one piece of data for each item.




-- 
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: commits-unsubscribe@inlong.apache.org

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



[GitHub] [incubator-inlong] baomingyu commented on a change in pull request #2806: [INLONG-2805][DataProxy] Add stream config log report

Posted by GitBox <gi...@apache.org>.
baomingyu commented on a change in pull request #2806:
URL: https://github.com/apache/incubator-inlong/pull/2806#discussion_r817667907



##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/sink/PulsarSink.java
##########
@@ -221,14 +224,32 @@ public void configure(Context context) {
         topicProperties = configManager.getTopicProperties();
         pulsarCluster = configManager.getThirdPartyClusterUrl2Token();
         pulsarConfig = configManager.getThirdPartyClusterConfig(); //pulsar common config
+        commonProperties = configManager.getCommonProperties();
         pulsarClientService = new PulsarClientService(pulsarConfig);
+        boolean enableReportConfigLog =
+                Boolean.parseBoolean(commonProperties
+                        .getOrDefault(ConfigConstants.CONFIG_LOG_REPORT_ENABLE,"true"));
+        localIp = NetworkUtils.getLocalIp();
+        if (enableReportConfigLog) {
+            String reportConfigServerUrl = commonProperties
+                    .getOrDefault(ConfigConstants.CONFIG_LOG_REPORT_SERVER_URL, "");
+            String reportConfigLogInterval = commonProperties
+                    .getOrDefault(ConfigConstants.CONFIG_LOG_REPORT_INTERVAL, "60000");
+            String clientVersion = commonProperties
+                    .getOrDefault(ConfigConstants.CONFIG_LOG_REPORT_CLIENT_VERSION, "");
+            streamConfigLogMetric = new StreamConfigLogMetric(ConfigConstants.COMPONENT_NAME,
+                    reportConfigServerUrl, Long.parseLong(reportConfigLogInterval),
+                    localIp, clientVersion);

Review comment:
       The indicator for jmx and prometheus already exists, here we need to add a reporting method




-- 
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: commits-unsubscribe@inlong.apache.org

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