EdColeman commented on code in PR #4459: URL: https://github.com/apache/accumulo/pull/4459#discussion_r1574937114
########## core/src/main/java/org/apache/accumulo/core/spi/metrics/MeterRegistryFactory.java: ########## @@ -0,0 +1,75 @@ +/* + * 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.spi.metrics; + +import java.util.Map; + +import org.apache.accumulo.core.spi.common.ServiceEnvironment; + +import io.micrometer.core.instrument.MeterRegistry; + +/** + * The Micrometer metrics allows for different monitoring systems. and can be enabled within + * Accumulo with properties and are initialized by implementing this interface and providing the + * factory implementation clas name as a property. Metrics are specified with the following + * properties: + * <p> + * Property.GENERAL_MICROMETER_ENABLED = true + * <p> + * Property.GENERAL_MICROMETER_FACTORY = [implementation].class.getName() + * <p> + * Properties can be passed in the Accumulo properties files using the prefix + * {@code general.custom.metrics.opts} for example. to set the polling rate used in the + * {@link org.apache.accumulo.core.spi.metrics.LoggingMeterRegistryFactory} to 10 seconds use + * + * <pre> + * general.custom.metrics.opts.logging.step = 10s + * </pre> + * + * Classes that implement custom properties will need to take care to implement unique names for + * each factory, if multiple factories are used. + * + * @since 2.1.3 + */ +public interface MeterRegistryFactory { + // full form in property file is "general.custom.metrics.opts" + String METRICS_PROP_SUBSTRING = "metrics.opts."; + + interface InitParameters { + /** + * + * @return The configured options. For example properties + * {@code general.custom.metrics.opts.prop1=abc} and + * {@code general.custom.metrics.opts.prop9=123} were set, then this map would contain + * {@code prop1=abc} and {@code prop9=123}. + */ + Map<String,String> getOptions(); + + ServiceEnvironment getServiceEnv(); + } + + default void init(InitParameters params) {} + + /** + * Called on metrics initialization. + * + * @return a Micrometer registry that will be added to the metrics configuration. + */ + MeterRegistry create(); Review Comment: The use of `ClassLoaderUtil.loadClass` to dynamically load the factories seems to complicate the use of a generic. Using the generic `T` gets flagged as a raw parameter usage when loading the classes in `MetricsInfoImpl` - and it is not obvious to me how to craft the signature. -- 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]
