Skip to content

Commit

Permalink
add leader_quantity
Browse files Browse the repository at this point in the history
  • Loading branch information
SpriCoder committed May 27, 2024
1 parent b161163 commit 640dfc6
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,35 +408,47 @@ private boolean loadLocally(LoadSingleTsFileNode node) throws IoTDBException {
}

// add metrics
if (!node.isGeneratedByConsensus()) {
DataRegion dataRegion =
StorageEngine.getInstance()
.getDataRegion(
(DataRegionId)
ConsensusGroupId.Factory.createFromTConsensusGroupId(
node.getLocalRegionReplicaSet().getRegionId()));

dataRegion
.getNonSystemDatabaseName()
.ifPresent(
databaseName -> {
// Report load tsFile points to IoTDB flush metrics
MemTableFlushTask.recordFlushPointsMetricInternal(
node.getWritePointCount(), databaseName, dataRegion.getDataRegionId());

DataRegion dataRegion =
StorageEngine.getInstance()
.getDataRegion(
(DataRegionId)
ConsensusGroupId.Factory.createFromTConsensusGroupId(
node.getLocalRegionReplicaSet().getRegionId()));

dataRegion
.getNonSystemDatabaseName()
.ifPresent(
databaseName -> {
// Report load tsFile points to IoTDB flush metrics
MemTableFlushTask.recordFlushPointsMetricInternal(
node.getWritePointCount(), databaseName, dataRegion.getDataRegionId());

MetricService.getInstance()
.count(
node.getWritePointCount(),
Metric.QUANTITY.toString(),
MetricLevel.CORE,
Tag.NAME.toString(),
Metric.POINTS_IN.toString(),
Tag.DATABASE.toString(),
databaseName,
Tag.REGION.toString(),
dataRegion.getDataRegionId());
if (!node.isGeneratedByConsensus()) {
MetricService.getInstance()
.count(
node.getWritePointCount(),
Metric.QUANTITY.toString(),
Metric.LEADER_QUANTITY.toString(),
MetricLevel.CORE,
Tag.NAME.toString(),
Metric.POINTS_IN.toString(),
Tag.DATABASE.toString(),
databaseName,
Tag.REGION.toString(),
dataRegion.getDataRegionId());
});
}
}
});

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,22 @@ public void insert(InsertRowNode insertRowNode) {

totalPointsNum += pointsInserted;

MetricService.getInstance()
.count(
pointsInserted,
Metric.QUANTITY.toString(),
MetricLevel.CORE,
Tag.NAME.toString(),
METRIC_POINT_IN,
Tag.DATABASE.toString(),
database,
Tag.REGION.toString(),
dataRegionId);
if (!insertRowNode.isGeneratedByConsensus()) {
MetricService.getInstance()
.count(
pointsInserted,
Metric.QUANTITY.toString(),
Metric.LEADER_QUANTITY.toString(),
MetricLevel.CORE,
Tag.NAME.toString(),
METRIC_POINT_IN,
Expand Down Expand Up @@ -266,11 +277,22 @@ public void insertAlignedRow(InsertRowNode insertRowNode) {
insertRowNode.getMeasurements().length - insertRowNode.getFailedMeasurementNumber();
totalPointsNum += pointsInserted;

MetricService.getInstance()
.count(
pointsInserted,
Metric.QUANTITY.toString(),
MetricLevel.CORE,
Tag.NAME.toString(),
METRIC_POINT_IN,
Tag.DATABASE.toString(),
database,
Tag.REGION.toString(),
dataRegionId);
if (!insertRowNode.isGeneratedByConsensus()) {
MetricService.getInstance()
.count(
pointsInserted,
Metric.QUANTITY.toString(),
Metric.LEADER_QUANTITY.toString(),
MetricLevel.CORE,
Tag.NAME.toString(),
METRIC_POINT_IN,
Expand All @@ -291,11 +313,22 @@ public void insertTablet(InsertTabletNode insertTabletNode, int start, int end)
(insertTabletNode.getDataTypes().length - insertTabletNode.getFailedMeasurementNumber())
* (end - start);
totalPointsNum += pointsInserted;
MetricService.getInstance()
.count(
pointsInserted,
Metric.QUANTITY.toString(),
MetricLevel.CORE,
Tag.NAME.toString(),
METRIC_POINT_IN,
Tag.DATABASE.toString(),
database,
Tag.REGION.toString(),
dataRegionId);
if (!insertTabletNode.isGeneratedByConsensus()) {
MetricService.getInstance()
.count(
pointsInserted,
Metric.QUANTITY.toString(),
Metric.LEADER_QUANTITY.toString(),
MetricLevel.CORE,
Tag.NAME.toString(),
METRIC_POINT_IN,
Expand All @@ -319,11 +352,22 @@ public void insertAlignedTablet(InsertTabletNode insertTabletNode, int start, in
(insertTabletNode.getDataTypes().length - insertTabletNode.getFailedMeasurementNumber())
* (end - start);
totalPointsNum += pointsInserted;
MetricService.getInstance()
.count(
pointsInserted,
Metric.QUANTITY.toString(),
MetricLevel.CORE,
Tag.NAME.toString(),
METRIC_POINT_IN,
Tag.DATABASE.toString(),
database,
Tag.REGION.toString(),
dataRegionId);
if (!insertTabletNode.isGeneratedByConsensus()) {
MetricService.getInstance()
.count(
pointsInserted,
Metric.QUANTITY.toString(),
Metric.LEADER_QUANTITY.toString(),
MetricLevel.CORE,
Tag.NAME.toString(),
METRIC_POINT_IN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public enum Metric {
CACHE("cache"),
CACHE_HIT_RATE("cache_hit"),
QUANTITY("quantity"),
LEADER_QUANTITY("leader_quantity"),
SCHEMA_REGION("schema_region"),
SCHEMA_ENGINE("schema_engine"),
// query engine related
Expand Down

0 comments on commit 640dfc6

Please sign in to comment.