morningman commented on a change in pull request #3635:
URL: https://github.com/apache/incubator-doris/pull/3635#discussion_r429979202
##########
File path: fe/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
##########
@@ -757,10 +759,15 @@ private boolean loadTxnCommitImpl(TLoadTxnCommitRequest
request) throws UserExce
throw new UserException("unknown database, database=" + dbName);
}
- return
Catalog.getCurrentGlobalTransactionMgr().commitAndPublishTransaction(
- db, request.getTxnId(),
- TabletCommitInfo.fromThrift(request.getCommitInfos()),
- 5000,
TxnCommitAttachment.fromThrift(request.txnCommitAttachment));
+ boolean ret =
Catalog.getCurrentGlobalTransactionMgr().commitAndPublishTransaction(
+ db, request.getTxnId(),
+ TabletCommitInfo.fromThrift(request.getCommitInfos()),
+ 5000,
TxnCommitAttachment.fromThrift(request.txnCommitAttachment));
+ if (ret) {
+ // if commit and publish is success, load can be regarded as
success
+ MetricRepo.COUNTER_LOAD_FINISHED.increase(1L);
Review comment:
public static LongCounterMetric COUNTER_TXN_REJECT;
public static LongCounterMetric COUNTER_TXN_BEGIN;
public static LongCounterMetric COUNTER_TXN_FAILED;
public static LongCounterMetric COUNTER_TXN_SUCCESS;
We already have 4 metrics to monitor the transaction, is it necessary to add
`COUNTER_LOAD_FINISHED` and `COUNTER_LOAD_ADD`?
##########
File path: be/src/http/action/metrics_action.cpp
##########
@@ -143,15 +143,74 @@ void SimpleCoreMetricsVisitor::visit(const std::string&
prefix,
}
}
+class JsonMetricsVisitor : public MetricsVisitor {
+public:
+ JsonMetricsVisitor() {
+ _ss << "[\n";
+ }
+ virtual ~JsonMetricsVisitor() {}
+ void visit(const std::string& prefix, const std::string& name,
+ MetricCollector* collector) override;
+ std::string to_string() {
+ std::string json = _ss.str();
+ json = json.substr(0, json.length() - 2);
+ json += "\n]\n";
+ return json;
+ }
+
+private:
+ std::stringstream _ss;
+};
+
+void JsonMetricsVisitor::visit(const std::string& prefix,
+ const std::string& name,
+ MetricCollector* collector) {
+ if (collector->empty() || name.empty()) {
+ return;
+ }
+ switch (collector->type()) {
+ case MetricType::COUNTER:
+ case MetricType::GAUGE:
+ for (auto& it : collector->metrics()) {
+ const MetricLabels& labels = it.first;
+ SimpleMetric* metric = reinterpret_cast<SimpleMetric*>(it.second);
+ _ss << "{\n\t\"tags\":\n\t{\n";
Review comment:
Why not using rapidjson lib to generate the json object?
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]