Search in sources :

Example 1 with OpenTelemetrySystem

use of org.hyperledger.besu.metrics.opentelemetry.OpenTelemetrySystem in project besu by hyperledger.

the class MetricsSystemFactory method create.

/**
 * Creates and starts a new metric system to observe the behavior of the client
 *
 * @param metricsConfiguration the configuration of the metric system
 * @return a new metric system
 */
public static ObservableMetricsSystem create(final MetricsConfiguration metricsConfiguration) {
    LOG.trace("Creating a metric system with {}", metricsConfiguration.getProtocol());
    if (!metricsConfiguration.isEnabled() && !metricsConfiguration.isPushEnabled()) {
        return new NoOpMetricsSystem();
    }
    if (PROMETHEUS.equals(metricsConfiguration.getProtocol())) {
        final PrometheusMetricsSystem metricsSystem = new PrometheusMetricsSystem(metricsConfiguration.getMetricCategories(), metricsConfiguration.isTimersEnabled());
        metricsSystem.init();
        return metricsSystem;
    } else if (OPENTELEMETRY.equals(metricsConfiguration.getProtocol())) {
        final OpenTelemetrySystem metricsSystem = new OpenTelemetrySystem(metricsConfiguration.getMetricCategories(), metricsConfiguration.isTimersEnabled(), metricsConfiguration.getPrometheusJob());
        metricsSystem.initDefaults();
        return metricsSystem;
    } else {
        throw new IllegalArgumentException("Invalid metrics protocol " + metricsConfiguration.getProtocol());
    }
}
Also used : PrometheusMetricsSystem(org.hyperledger.besu.metrics.prometheus.PrometheusMetricsSystem) OpenTelemetrySystem(org.hyperledger.besu.metrics.opentelemetry.OpenTelemetrySystem) NoOpMetricsSystem(org.hyperledger.besu.metrics.noop.NoOpMetricsSystem)

Aggregations

NoOpMetricsSystem (org.hyperledger.besu.metrics.noop.NoOpMetricsSystem)1 OpenTelemetrySystem (org.hyperledger.besu.metrics.opentelemetry.OpenTelemetrySystem)1 PrometheusMetricsSystem (org.hyperledger.besu.metrics.prometheus.PrometheusMetricsSystem)1