keith-turner commented on code in PR #5798:
URL: https://github.com/apache/accumulo/pull/5798#discussion_r2286434246
##########
core/src/main/java/org/apache/accumulo/core/fate/FateExecutor.java:
##########
@@ -75,23 +78,27 @@ public class FateExecutor<T> {
private final Set<TransactionRunner> runningTxRunners;
private final Set<Fate.FateOperation> fateOps;
private final ConcurrentLinkedQueue<Integer> idleCountHistory = new
ConcurrentLinkedQueue<>();
+ private final FateExecutorMetrics<T> fateExecutorMetrics;
public FateExecutor(Fate<T> fate, T environment, Set<Fate.FateOperation>
fateOps, int poolSize) {
- final String operatesOn = fate.getStore().type().name().toLowerCase() + "."
- + fateOps.stream().map(fo ->
fo.name().toLowerCase()).collect(Collectors.joining("."));
+ final FateInstanceType type = fate.getStore().type();
+ final String typeStr = type.name().toLowerCase();
+ final String operatesOn =
+ fateOps.stream().map(fo ->
fo.name().toLowerCase()).collect(Collectors.joining("."));
Review Comment:
Could sort the names prior to joining since this is a user facing string.
```suggestion
fateOps.stream().map(fo ->
fo.name().toLowerCase()).sorted().collect(Collectors.joining("."));
```
##########
core/src/main/java/org/apache/accumulo/core/fate/FateExecutorMetrics.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.core.fate;
+
+import java.util.Set;
+import java.util.concurrent.TransferQueue;
+
+import org.apache.accumulo.core.metrics.Metric;
+import org.apache.accumulo.core.metrics.MetricsProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.micrometer.core.instrument.Gauge;
+import io.micrometer.core.instrument.MeterRegistry;
+
+public class FateExecutorMetrics<T> implements MetricsProducer {
+ private static final Logger log =
LoggerFactory.getLogger(FateExecutorMetrics.class.getName());
+ private final FateInstanceType type;
+ private final String operatesOn;
+ private final Set<FateExecutor<T>.TransactionRunner> runningTxRunners;
+ private final TransferQueue<FateId> workQueue;
+ private MeterRegistry registry;
+ public static final String INSTANCE_TYPE_TAG_KEY = "instanceType";
+ public static final String OPS_ASSIGNED_TAG_KEY = "ops.assigned";
+
+ protected FateExecutorMetrics(FateInstanceType type, String operatesOn,
+ Set<FateExecutor<T>.TransactionRunner> runningTxRunners,
TransferQueue<FateId> workQueue) {
+ this.type = type;
+ this.operatesOn = operatesOn;
+ this.runningTxRunners = runningTxRunners;
+ this.workQueue = workQueue;
+ }
+
+ @Override
+ public void registerMetrics(MeterRegistry registry) {
+ Gauge.builder(Metric.FATE_OPS_THREADS_TOTAL.getName(),
runningTxRunners::size)
+ .description(Metric.FATE_OPS_THREADS_TOTAL.getDescription())
+ .tag(INSTANCE_TYPE_TAG_KEY,
type.name().toLowerCase()).tag(OPS_ASSIGNED_TAG_KEY, operatesOn)
Review Comment:
Seems like operatesOn could be a really long string. Wonder if that could
cause problems for any metrics systems. Also wondering if we could shorten it
in anyway, like if it is operating on all operations with the TABLE prefix then
replace that with `TABLE_*`.
--
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]