You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by "doleyzi (via GitHub)" <gi...@apache.org> on 2024/08/19 11:01:38 UTC
[PR] [INLONG-10793][SDK] Added metric management for DataProxy CPP SDK [inlong]
doleyzi opened a new pull request, #10815:
URL: https://github.com/apache/inlong/pull/10815
- Fixes #10793
### Motivation
Added metric management for DataProxy CPP SDK
### Modifications
Added metric management for DataProxy CPP SDK to facilitate system operation
--
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
Re: [PR] [INLONG-10793][SDK] Added metric management for DataProxy CPP SDK [inlong]
Posted by "dockerzhang (via GitHub)" <gi...@apache.org>.
dockerzhang merged PR #10815:
URL: https://github.com/apache/inlong/pull/10815
--
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
Re: [PR] [INLONG-10793][SDK] Added metric management for DataProxy CPP SDK [inlong]
Posted by "luchunliang (via GitHub)" <gi...@apache.org>.
luchunliang commented on code in PR #10815:
URL: https://github.com/apache/inlong/pull/10815#discussion_r1721622344
##########
inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/src/manager/metric_manager.cc:
##########
@@ -0,0 +1,64 @@
+/**
+ * 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.
+ */
+
+#include "metric_manager.h"
+
+#include <rapidjson/document.h>
+#include <sys/prctl.h>
+#include <unistd.h>
+
+#include "../utils/logger.h"
+#include "../utils/utils.h"
+#include "../utils/capi_constant.h"
+
+namespace inlong {
+void MetricManager::Init() {
+ if (__sync_bool_compare_and_swap(&inited_, false, true)) {
+ update_thread_ = std::thread(&MetricManager::Run, this);
+ }
+ InitEnvironment();
+}
+void MetricManager::InitEnvironment() {
+ environment_.setType("cpp");
+ environment_.setVersion(constants::kVersion);
+ environment_.setPid(getpid());
+ environment_.setIp(SdkConfig::getInstance()->local_ip_);
+}
+void MetricManager::Run() {
+ prctl(PR_SET_NAME, "metric-manager");
+ while (running_) {
+ LOG_INFO("Start report metric");
+ PrintMetric();
+ std::this_thread::sleep_for(std::chrono::minutes(constants::kMetricIntervalMinutes));
+ }
+}
+void MetricManager::PrintMetric() {
Review Comment:
The class name and variable name do not conform to C++ coding style.
--
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
Re: [PR] [INLONG-10793][SDK] Added metric management for DataProxy CPP SDK [inlong]
Posted by "doleyzi (via GitHub)" <gi...@apache.org>.
doleyzi commented on code in PR #10815:
URL: https://github.com/apache/inlong/pull/10815#discussion_r1721640599
##########
inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/src/manager/metric_manager.cc:
##########
@@ -0,0 +1,64 @@
+/**
+ * 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.
+ */
+
+#include "metric_manager.h"
+
+#include <rapidjson/document.h>
+#include <sys/prctl.h>
+#include <unistd.h>
+
+#include "../utils/logger.h"
+#include "../utils/utils.h"
+#include "../utils/capi_constant.h"
+
+namespace inlong {
+void MetricManager::Init() {
+ if (__sync_bool_compare_and_swap(&inited_, false, true)) {
+ update_thread_ = std::thread(&MetricManager::Run, this);
+ }
+ InitEnvironment();
+}
+void MetricManager::InitEnvironment() {
+ environment_.setType("cpp");
+ environment_.setVersion(constants::kVersion);
+ environment_.setPid(getpid());
+ environment_.setIp(SdkConfig::getInstance()->local_ip_);
+}
+void MetricManager::Run() {
+ prctl(PR_SET_NAME, "metric-manager");
+ while (running_) {
+ LOG_INFO("Start report metric");
+ PrintMetric();
+ std::this_thread::sleep_for(std::chrono::minutes(constants::kMetricIntervalMinutes));
+ }
+}
+void MetricManager::PrintMetric() {
Review Comment:
Uniformly follow Google specifications, that is, function names are named in camel case.
--
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