This is an automated email from the ASF dual-hosted git repository. domgarguilo pushed a commit to branch 2.1 in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push: new 7f9d3f3efe Emit block cache metrics (#4518) 7f9d3f3efe is described below commit 7f9d3f3efe5090d9d8971833bcb0177865722189 Author: Dom G <domgargu...@apache.org> AuthorDate: Tue May 7 14:50:23 2024 -0400 Emit block cache metrics (#4518) * Emit block cache metrics from tserver and scan server --- .../accumulo/core/metrics/MetricsProducer.java | 9 ++++ .../apache/accumulo/tserver/BlockCacheMetrics.java | 61 ++++++++++++++++++++++ .../org/apache/accumulo/tserver/ScanServer.java | 5 +- .../org/apache/accumulo/tserver/TabletServer.java | 8 ++- 4 files changed, 80 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/metrics/MetricsProducer.java b/core/src/main/java/org/apache/accumulo/core/metrics/MetricsProducer.java index 1bb2a1c10e..2da6303b5d 100644 --- a/core/src/main/java/org/apache/accumulo/core/metrics/MetricsProducer.java +++ b/core/src/main/java/org/apache/accumulo/core/metrics/MetricsProducer.java @@ -667,6 +667,15 @@ public interface MetricsProducer { String METRICS_UPDATE_WALOG_WRITE = METRICS_UPDATE_PREFIX + "walog.write"; String METRICS_UPDATE_MUTATION_ARRAY_SIZE = METRICS_UPDATE_PREFIX + "mutation.arrays.size"; + String METRICS_BLOCKCACHE_PREFIX = "accumulo.blockcache."; + String METRICS_BLOCKCACHE_INDEX_HITCOUNT = METRICS_BLOCKCACHE_PREFIX + "index.hitcount"; + String METRICS_BLOCKCACHE_INDEX_REQUESTCOUNT = METRICS_BLOCKCACHE_PREFIX + "index.requestcount"; + String METRICS_BLOCKCACHE_DATA_HITCOUNT = METRICS_BLOCKCACHE_PREFIX + "data.hitcount"; + String METRICS_BLOCKCACHE_DATA_REQUESTCOUNT = METRICS_BLOCKCACHE_PREFIX + "data.requestcount"; + String METRICS_BLOCKCACHE_SUMMARY_HITCOUNT = METRICS_BLOCKCACHE_PREFIX + "summary.hitcount"; + String METRICS_BLOCKCACHE_SUMMARY_REQUESTCOUNT = + METRICS_BLOCKCACHE_PREFIX + "summary.requestcount"; + /** * Build Micrometer Meter objects and register them with the registry */ diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/BlockCacheMetrics.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/BlockCacheMetrics.java new file mode 100644 index 0000000000..ca3fc6c72f --- /dev/null +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/BlockCacheMetrics.java @@ -0,0 +1,61 @@ +/* + * 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 + * + * https://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.accumulo.tserver; + +import java.util.function.ToDoubleFunction; + +import org.apache.accumulo.core.metrics.MetricsProducer; +import org.apache.accumulo.core.spi.cache.BlockCache; + +import io.micrometer.core.instrument.FunctionCounter; +import io.micrometer.core.instrument.MeterRegistry; + +public class BlockCacheMetrics implements MetricsProducer { + + BlockCache indexCache; + BlockCache dataCache; + BlockCache summaryCache; + + public BlockCacheMetrics(BlockCache indexCache, BlockCache dataCache, BlockCache summaryCache) { + this.indexCache = indexCache; + this.dataCache = dataCache; + this.summaryCache = summaryCache; + } + + @Override + public void registerMetrics(MeterRegistry registry) { + ToDoubleFunction<BlockCache> getHitCount = cache -> cache.getStats().hitCount(); + ToDoubleFunction<BlockCache> getRequestCount = cache -> cache.getStats().requestCount(); + + FunctionCounter.builder(METRICS_BLOCKCACHE_INDEX_HITCOUNT, indexCache, getHitCount) + .description("Index block cache hit count").register(registry); + FunctionCounter.builder(METRICS_BLOCKCACHE_INDEX_REQUESTCOUNT, indexCache, getRequestCount) + .description("Index block cache request count").register(registry); + + FunctionCounter.builder(METRICS_BLOCKCACHE_DATA_HITCOUNT, dataCache, getHitCount) + .description("Data block cache hit count").register(registry); + FunctionCounter.builder(METRICS_BLOCKCACHE_DATA_REQUESTCOUNT, dataCache, getRequestCount) + .description("Data block cache request count").register(registry); + + FunctionCounter.builder(METRICS_BLOCKCACHE_SUMMARY_HITCOUNT, summaryCache, getHitCount) + .description("Summary block cache hit count").register(registry); + FunctionCounter.builder(METRICS_BLOCKCACHE_SUMMARY_REQUESTCOUNT, summaryCache, getRequestCount) + .description("Summary block cache request count").register(registry); + } +} diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/ScanServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/ScanServer.java index 1e237e80e8..dabcc617d1 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/ScanServer.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/ScanServer.java @@ -203,6 +203,7 @@ public class ScanServer extends AbstractServer private ServiceLock scanServerLock; protected TabletServerScanMetrics scanMetrics; private ScanServerMetrics scanServerMetrics; + private BlockCacheMetrics blockCacheMetrics; private ZooCache managerLockCache; @@ -380,8 +381,10 @@ public class ScanServer extends AbstractServer scanMetrics = new TabletServerScanMetrics(); scanServerMetrics = new ScanServerMetrics(tabletMetadataCache); + blockCacheMetrics = new BlockCacheMetrics(resourceManager.getIndexCache(), + resourceManager.getDataCache(), resourceManager.getSummaryCache()); - metricsInfo.addMetricsProducers(scanMetrics, scanServerMetrics); + metricsInfo.addMetricsProducers(scanMetrics, scanServerMetrics, blockCacheMetrics); metricsInfo.init(); // We need to set the compaction manager so that we don't get an NPE in CompactableImpl.close diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java index b24c7cf30d..85b0872385 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java @@ -187,6 +187,7 @@ public class TabletServer extends AbstractServer implements TabletHostingServer TabletServerScanMetrics scanMetrics; TabletServerMinCMetrics mincMetrics; CompactionExecutorsMetrics ceMetrics; + BlockCacheMetrics blockCacheMetrics; @Override public TabletServerScanMetrics getScanMetrics() { @@ -759,7 +760,7 @@ public class TabletServer extends AbstractServer implements TabletHostingServer throw new RuntimeException("Failed to start the tablet client service", e1); } - MetricsInfo metricsInfo = getContext().getMetricsInfo(); + MetricsInfo metricsInfo = context.getMetricsInfo(); metricsInfo.addServiceTags(getApplicationName(), clientAddress); metrics = new TabletServerMetrics(this); @@ -767,8 +768,11 @@ public class TabletServer extends AbstractServer implements TabletHostingServer scanMetrics = new TabletServerScanMetrics(); mincMetrics = new TabletServerMinCMetrics(); ceMetrics = new CompactionExecutorsMetrics(); + blockCacheMetrics = new BlockCacheMetrics(this.resourceManager.getIndexCache(), + this.resourceManager.getDataCache(), this.resourceManager.getSummaryCache()); - metricsInfo.addMetricsProducers(metrics, updateMetrics, scanMetrics, mincMetrics, ceMetrics); + metricsInfo.addMetricsProducers(metrics, updateMetrics, scanMetrics, mincMetrics, ceMetrics, + blockCacheMetrics); metricsInfo.init(); this.compactionManager = new CompactionManager(() -> Iterators