This is an automated email from the ASF dual-hosted git repository. dlmarion pushed a commit to branch elasticity in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/elasticity by this push: new afe9a8a87e Add resourceGroup as a tag in the emitted metrics (#3992) afe9a8a87e is described below commit afe9a8a87ea665ca89056208b4f8f0b91f8ce9b7 Author: Dave Marion <dlmar...@apache.org> AuthorDate: Thu Nov 30 16:08:16 2023 -0500 Add resourceGroup as a tag in the emitted metrics (#3992) Related to #3991 --- .../apache/accumulo/core/metrics/MetricsUtil.java | 20 +++++++++++--------- .../org/apache/accumulo/compactor/Compactor.java | 2 +- .../apache/accumulo/gc/SimpleGarbageCollector.java | 2 +- .../java/org/apache/accumulo/manager/Manager.java | 2 +- .../java/org/apache/accumulo/tserver/ScanServer.java | 2 +- .../org/apache/accumulo/tserver/TabletServer.java | 2 +- .../org/apache/accumulo/test/metrics/MetricsIT.java | 5 ++++- 7 files changed, 20 insertions(+), 15 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/metrics/MetricsUtil.java b/core/src/main/java/org/apache/accumulo/core/metrics/MetricsUtil.java index 57bd50bb3b..cb9b9481c3 100644 --- a/core/src/main/java/org/apache/accumulo/core/metrics/MetricsUtil.java +++ b/core/src/main/java/org/apache/accumulo/core/metrics/MetricsUtil.java @@ -53,19 +53,21 @@ public class MetricsUtil { private static Pattern camelCasePattern = Pattern.compile("[a-z][A-Z][a-z]"); public static void initializeMetrics(final AccumuloConfiguration conf, final String appName, - final HostAndPort address, final String instanceName) throws ClassNotFoundException, - InstantiationException, IllegalAccessException, IllegalArgumentException, - InvocationTargetException, NoSuchMethodException, SecurityException { + final HostAndPort address, final String instanceName, final String resourceGroup) + throws ClassNotFoundException, InstantiationException, IllegalAccessException, + IllegalArgumentException, InvocationTargetException, NoSuchMethodException, + SecurityException { initializeMetrics(conf.getBoolean(Property.GENERAL_MICROMETER_ENABLED), conf.getBoolean(Property.GENERAL_MICROMETER_JVM_METRICS_ENABLED), - conf.get(Property.GENERAL_MICROMETER_FACTORY), appName, address, instanceName); + conf.get(Property.GENERAL_MICROMETER_FACTORY), appName, address, instanceName, + resourceGroup); } private static void initializeMetrics(boolean enabled, boolean jvmMetricsEnabled, - String factoryClass, String appName, HostAndPort address, String instanceName) - throws ClassNotFoundException, InstantiationException, IllegalAccessException, - IllegalArgumentException, InvocationTargetException, NoSuchMethodException, - SecurityException { + String factoryClass, String appName, HostAndPort address, String instanceName, + String resourceGroup) throws ClassNotFoundException, InstantiationException, + IllegalAccessException, IllegalArgumentException, InvocationTargetException, + NoSuchMethodException, SecurityException { LOG.info("initializing metrics, enabled:{}, class:{}", enabled, factoryClass); @@ -80,7 +82,7 @@ public class MetricsUtil { List<Tag> tags = new ArrayList<>(); tags.add(Tag.of("instance.name", instanceName)); tags.add(Tag.of("process.name", processName)); - + tags.add(Tag.of("resource.group", resourceGroup)); if (address != null) { if (!address.getHost().isEmpty()) { tags.add(Tag.of("host", address.getHost())); diff --git a/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java b/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java index 73ac3e2e83..9e3c81504c 100644 --- a/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java +++ b/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java @@ -613,7 +613,7 @@ public class Compactor extends AbstractServer implements MetricsProducer, Compac try { MetricsUtil.initializeMetrics(getContext().getConfiguration(), this.applicationName, - clientAddress, getContext().getInstanceName()); + clientAddress, getContext().getInstanceName(), this.getResourceGroup()); pausedMetrics = new PausedCompactionMetrics(); MetricsUtil.initializeProducers(this, pausedMetrics); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java b/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java index e52d63291a..6bfb5b07c5 100644 --- a/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java +++ b/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java @@ -158,7 +158,7 @@ public class SimpleGarbageCollector extends AbstractServer implements Iface { try { MetricsUtil.initializeMetrics(getContext().getConfiguration(), this.applicationName, address, - getContext().getInstanceName()); + getContext().getInstanceName(), this.getResourceGroup()); MetricsUtil.initializeProducers(this, new GcMetrics(this)); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java b/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java index 33bad0834c..b23e0a6bdb 100644 --- a/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java +++ b/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java @@ -980,7 +980,7 @@ public class Manager extends AbstractServer ManagerMetrics mm = new ManagerMetrics(getConfiguration(), this); try { MetricsUtil.initializeMetrics(getContext().getConfiguration(), this.applicationName, - sa.getAddress(), getContext().getInstanceName()); + sa.getAddress(), getContext().getInstanceName(), this.getResourceGroup()); MetricsUtil.initializeProducers(this, mm); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException 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 3678108e19..a08e888cc3 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 @@ -371,7 +371,7 @@ public class ScanServer extends AbstractServer try { MetricsUtil.initializeMetrics(getContext().getConfiguration(), this.applicationName, - clientAddress, getContext().getInstanceName()); + clientAddress, getContext().getInstanceName(), this.getResourceGroup()); scanMetrics = new TabletServerScanMetrics(); MetricsUtil.initializeProducers(this, scanMetrics); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException 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 db52309f51..5942a367a5 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 @@ -583,7 +583,7 @@ public class TabletServer extends AbstractServer implements TabletHostingServer try { MetricsUtil.initializeMetrics(context.getConfiguration(), this.applicationName, clientAddress, - getContext().getInstanceName()); + getContext().getInstanceName(), this.getResourceGroup()); metrics = new TabletServerMetrics(this); updateMetrics = new TabletServerUpdateMetrics(); diff --git a/test/src/main/java/org/apache/accumulo/test/metrics/MetricsIT.java b/test/src/main/java/org/apache/accumulo/test/metrics/MetricsIT.java index 5cf42bca52..a9d351dc52 100644 --- a/test/src/main/java/org/apache/accumulo/test/metrics/MetricsIT.java +++ b/test/src/main/java/org/apache/accumulo/test/metrics/MetricsIT.java @@ -163,7 +163,7 @@ public class MetricsIT extends ConfigurableMacBase implements MetricsProducer { writer.addMutation(m); } } - client.tableOperations().compact(tableName, new CompactionConfig()); + client.tableOperations().compact(tableName, new CompactionConfig().setWait(true)); try (Scanner scanner = client.createScanner(tableName)) { scanner.forEach((k, v) -> {}); } @@ -197,6 +197,9 @@ public class MetricsIT extends ConfigurableMacBase implements MetricsProducer { assertNotEquals("0.0.0.0", a.getTags().get("host")); assertNotNull(a.getTags().get("instance.name")); + // check resource.group tag exists + assertNotNull(a.getTags().get("resource.group")); + // check the length of the tag value is sane final int MAX_EXPECTED_TAG_LEN = 128; a.getTags().forEach((k, v) -> assertTrue(v.length() < MAX_EXPECTED_TAG_LEN));