All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.swirlds.common.metrics.PlatformMetricsFactory Maven / Gradle / Ivy

Go to download

Swirlds is a software platform designed to build fully-distributed applications that harness the power of the cloud without servers. Now you can develop applications with fairness in decision making, speed, trust and reliability, at a fraction of the cost of traditional server-based platforms.

There is a newer version: 0.56.6
Show newest version
/*
 * Copyright (C) 2022-2024 Hedera Hashgraph, LLC
 *
 * Licensed 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 com.swirlds.common.metrics;

import com.swirlds.metrics.api.Metric;
import com.swirlds.metrics.api.MetricConfig;
import com.swirlds.metrics.api.MetricsFactory;
import edu.umd.cs.findbugs.annotations.NonNull;
import java.util.Objects;

/**
 * Factory for all {@link Metric}-implementations
 */
public interface PlatformMetricsFactory extends MetricsFactory {

    /**
     * Creates a {@link DurationGauge}
     *
     * @param config the configuration
     * @return the new {@link DurationGauge}
     * @throws IllegalArgumentException if {@code config} is {@code null}
     */
    DurationGauge createDurationGauge(final DurationGauge.Config config);

    /**
     * Creates a {@link FunctionGauge}
     *
     * @param config the configuration
     * @param     the type of the value that will be contained in the {@code FunctionGauge}
     * @return the new {@code FunctionGauge}
     * @throws IllegalArgumentException if {@code config} is {@code null}
     */
     FunctionGauge createFunctionGauge(final FunctionGauge.Config config);

    /**
     * Creates a {@link IntegerPairAccumulator}
     *
     * @param config
     * 		the configuration
     * @return the new {@code IntegerPairAccumulator}
     * @throws IllegalArgumentException
     * 		if {@code config} is {@code null}
     */
     IntegerPairAccumulator createIntegerPairAccumulator(IntegerPairAccumulator.Config config);

    /**
     * Creates a {@link RunningAverageMetric}
     *
     * @param config
     * 		the configuration
     * @return the new {@code RunningAverageMetric}
     * @throws IllegalArgumentException
     * 		if {@code config} is {@code null}
     */
    RunningAverageMetric createRunningAverageMetric(final RunningAverageMetric.Config config);

    /**
     * Creates a {@link SpeedometerMetric}
     *
     * @param config
     * 		the configuration
     * @return the new {@code SpeedometerMetric}
     * @throws IllegalArgumentException
     * 		if {@code config} is {@code null}
     */
    SpeedometerMetric createSpeedometerMetric(final SpeedometerMetric.Config config);

    /**
     * Creates a {@link StatEntry}
     *
     * @param config
     * 		the configuration
     * @return the new {@code StatEntry}
     * @throws IllegalArgumentException
     * 		if {@code config} is {@code null}
     */
    @SuppressWarnings("removal")
    StatEntry createStatEntry(final StatEntry.Config config);

    /**
     * Creates a {@link Metric}.
     * 

* The default implementation calls the appropriate method within this factory. * * @param config * the configuration * @return the new {@code Metric} * @param sub-interface of the generated {@code Metric} */ default T createMetric(@NonNull final MetricConfig config) { Objects.requireNonNull(config, "config"); // We use the double-dispatch pattern to create a Metric. This simplifies the API, because it allows us // to have a single method for all types of metrics. (The alternative would have been a method like // getOrCreateCounter() for each type of metric.) // // This method here call MetricConfig.create() providing the MetricsFactory. This method is overridden by // each subclass of MetricConfig to call the specific method in MetricsFactory, i.e. Counter.Config // calls MetricsFactory.createCounter(). return config.create(this); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy