You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2021/09/16 11:02:28 UTC

[GitHub] [accumulo] dlmarion commented on a change in pull request #2188: WIP: Add micrometer metrics implementation

dlmarion commented on a change in pull request #2188:
URL: https://github.com/apache/accumulo/pull/2188#discussion_r710011984



##########
File path: server/base/src/main/java/org/apache/accumulo/server/metrics/service/MicrometerMetricsFactory.java
##########
@@ -0,0 +1,182 @@
+/*
+ * 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
+ *
+ *   http://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.server.metrics.service;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.ServiceLoader;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.server.ServerContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.micrometer.core.instrument.Meter;
+import io.micrometer.core.instrument.MeterRegistry;
+import io.micrometer.core.instrument.composite.CompositeMeterRegistry;
+import io.micrometer.core.instrument.config.MeterFilter;
+import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
+
+public class MicrometerMetricsFactory {
+
+  private static final Pattern MATCH_ON_NAME =
+      Pattern.compile("metrics.service.(?<index>\\d+).name");
+
+  private static final Property METRICS_CONFIG_PROPERTIES =
+      Property.GENERAL_METRICS_CONFIGURATION_PROPERTIES_FILE;
+
+  private static final Logger log = LoggerFactory.getLogger(MicrometerMetricsFactory.class);
+  public static final String CALLING_SERVICE_NAME = "callingServiceName";
+
+  private final CompositeMeterRegistry registry;
+
+  private MicrometerMetricsFactory(final ServerContext context, final String appName) {
+
+    registry = new CompositeMeterRegistry();
+    // Configure replication metrics to display percentiles and change its expiry to 10 mins
+    registry.config().meterFilter(new MeterFilter() {
+      @Override
+      public DistributionStatisticConfig configure(Meter.Id id,
+          DistributionStatisticConfig config) {
+        if (id.getName().equals("replicationQueue")) {
+          return DistributionStatisticConfig.builder().percentiles(0.5, 0.75, 0.9, 0.95, 0.99)
+              .expiry(Duration.ofMinutes(10)).build().merge(config);
+        }
+        return config;
+      }
+    });
+
+    var propKey = METRICS_CONFIG_PROPERTIES.getKey();

Review comment:
       Is there a reason that we have to have a configuration file in Accumulo for these pluggable Registries? Can't implementations of the MetricsRegistrationService configure the Registry in its own way?




-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org