Skip to content

Commit

Permalink
[Feature] adds index_uuid as a tag in node stats all shard metrics (#680
Browse files Browse the repository at this point in the history
)

* Adds index_uuid as a dimension for node stats col

Signed-off-by: Atharva Sharma <[email protected]>

* updates gauge usage and added index_uuid as tag

Signed-off-by: Atharva Sharma <[email protected]>

* removed incomplete collector

Signed-off-by: Atharva Sharma <[email protected]>

* fixed UTs after gauge changes

Signed-off-by: Atharva Sharma <[email protected]>

* addressed comments

Signed-off-by: Atharva Sharma <[email protected]>

* reverted gauge related changes

Signed-off-by: Atharva Sharma <[email protected]>

---------

Signed-off-by: Atharva Sharma <[email protected]>
  • Loading branch information
atharvasharma61 authored Jul 23, 2024
1 parent c95feb6 commit 948b54a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ configOverridesWrapper, getCollectorName())) {
// Populating value for the first run.
recordMetrics(
new NodeStatsMetricsAllShardsPerCollectionStatus(currentShardStats),
shardId.getIndexName(),
String.valueOf(shardId.id()));
shardId);
continue;
}
ShardStats prevShardStats = prevPerShardStats.get(shardId);
Expand All @@ -153,15 +152,14 @@ configOverridesWrapper, getCollectorName())) {
// run.
recordMetrics(
new NodeStatsMetricsAllShardsPerCollectionStatus(currentShardStats),
shardId.getIndexName(),
String.valueOf(shardId.id()));
shardId);
continue;
}
NodeStatsMetricsAllShardsPerCollectionStatus prevValue =
new NodeStatsMetricsAllShardsPerCollectionStatus(prevShardStats);
NodeStatsMetricsAllShardsPerCollectionStatus currValue =
new NodeStatsMetricsAllShardsPerCollectionStatus(currentShardStats);
populateDiffMetricValue(prevValue, currValue, shardId.getIndexName(), shardId.id());
populateDiffMetricValue(prevValue, currValue, shardId);
}
}

Expand Down Expand Up @@ -243,13 +241,20 @@ public void populatePerShardStats(IndicesService indicesService) {
}

private void recordMetrics(
NodeStatsMetricsAllShardsPerCollectionStatus metrics,
String indexName,
String shardId) {
NodeStatsMetricsAllShardsPerCollectionStatus metrics, ShardId shardId) {
Tags nodeStatsMetricsTag =
Tags.create()
.addTag(RTFMetrics.CommonDimension.INDEX_NAME.toString(), indexName)
.addTag(RTFMetrics.CommonDimension.SHARD_ID.toString(), shardId);
.addTag(
RTFMetrics.CommonDimension.INDEX_NAME.toString(),
shardId.getIndexName())
.addTag(
RTFMetrics.CommonDimension.SHARD_ID.toString(),
String.valueOf(shardId.getId()));

if (shardId.getIndex() != null) {
nodeStatsMetricsTag.addTag(
RTFMetrics.CommonDimension.INDEX_UUID.toString(), shardId.getIndex().getUUID());
}

cacheQueryMissMetrics.add(metrics.getQueryCacheMissCount(), nodeStatsMetricsTag);
cacheQuerySizeMetrics.add(metrics.getQueryCacheInBytes(), nodeStatsMetricsTag);
Expand All @@ -267,8 +272,7 @@ private void recordMetrics(
public void populateDiffMetricValue(
NodeStatsMetricsAllShardsPerCollectionStatus prevValue,
NodeStatsMetricsAllShardsPerCollectionStatus currValue,
String indexName,
int shardId) {
ShardId shardId) {

NodeStatsMetricsAllShardsPerCollectionStatus metrics =
new NodeStatsMetricsAllShardsPerCollectionStatus(
Expand All @@ -289,7 +293,7 @@ public void populateDiffMetricValue(
0),
currValue.requestCacheInBytes);

recordMetrics(metrics, indexName, String.valueOf(shardId));
recordMetrics(metrics, shardId);
}

public static class NodeStatsMetricsAllShardsPerCollectionStatus extends MetricStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ public void testCollectMetrics() throws IOException {
createIndex(TEST_INDEX);
rtfNodeStatsAllShardsMetricsCollector.collectMetrics(startTimeInMills);
verify(rtfNodeStatsAllShardsMetricsCollector, never())
.populateDiffMetricValue(any(), any(), anyString(), anyInt());
.populateDiffMetricValue(any(), any(), any());
startTimeInMills += 500;
rtfNodeStatsAllShardsMetricsCollector.collectMetrics(startTimeInMills);
verify(rtfNodeStatsAllShardsMetricsCollector, times(1))
.populateDiffMetricValue(any(), any(), anyString(), anyInt());
.populateDiffMetricValue(any(), any(), any());
verify(cacheFieldDataEvictionCounter, atLeastOnce()).add(anyDouble(), any());
verify(cacheFieldDataSizeCounter, atLeastOnce()).add(anyDouble(), any());
verify(cacheQueryMissCounter, atLeastOnce()).add(anyDouble(), any());
Expand Down

0 comments on commit 948b54a

Please sign in to comment.