dlmarion commented on code in PR #4461: URL: https://github.com/apache/accumulo/pull/4461#discussion_r1586320791
########## server/tserver/src/main/java/org/apache/accumulo/tserver/ScanServerMetrics.java: ########## @@ -0,0 +1,68 @@ +/* + * 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.List; + +import org.apache.accumulo.core.dataImpl.KeyExtent; +import org.apache.accumulo.core.metadata.schema.TabletMetadata; +import org.apache.accumulo.core.metrics.MetricsProducer; + +import com.github.benmanes.caffeine.cache.LoadingCache; + +import io.micrometer.core.instrument.Counter; +import io.micrometer.core.instrument.MeterRegistry; +import io.micrometer.core.instrument.Tag; +import io.micrometer.core.instrument.Timer; +import io.micrometer.core.instrument.binder.cache.CaffeineCacheMetrics; + +public class ScanServerMetrics implements MetricsProducer { + + private final String resourceGroup; + private Timer reservationTimer; + private Counter busyTimeoutCount; + + private final LoadingCache<KeyExtent,TabletMetadata> tabletMetadataCache; + + public ScanServerMetrics(final LoadingCache<KeyExtent,TabletMetadata> tabletMetadataCache, + String resourceGroup) { + this.tabletMetadataCache = tabletMetadataCache; + this.resourceGroup = resourceGroup; + } + + @Override + public void registerMetrics(MeterRegistry registry) { + reservationTimer = Timer.builder(MetricsProducer.METRICS_SCAN_RESERVATION_TIMER) + .description("Time to reserve a tablets files for scan") + .tag("resource.group", resourceGroup).register(registry); + busyTimeoutCount = + Counter.builder(METRICS_SCAN_BUSY_TIMEOUT_COUNTER).tag("resource.group", resourceGroup) + .description("The number of scans where a busy timeout happened").register(registry); + CaffeineCacheMetrics.monitor(registry, tabletMetadataCache, METRICS_SCAN_TABLET_METADATA_CACHE, + List.of(Tag.of("resource.group", resourceGroup))); Review Comment: This might be able to be removed on the merge to elasticity. The [Caches](https://github.com/apache/accumulo/blob/elasticity/core/src/main/java/org/apache/accumulo/core/util/cache/Caches.java) class is used in elasticity and it conditionally sets up metrics. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
