static Optional<MetricsService> create(
      final MetricsConfiguration configuration, final MetricsSystem metricsSystem) {
    LoggerFactory.getLogger(MetricsService.class)
        .trace("Creating metrics service {}", configuration.getProtocol());
    if (configuration.getProtocol() == MetricsProtocol.PROMETHEUS) {
      if (configuration.isEnabled()) {
        return Optional.of(
            new MetricsHttpService(configuration, (PrometheusMetricsSystem) metricsSystem));
      } else if (configuration.isPushEnabled()) {
        return Optional.of(
            new MetricsPushGatewayService(configuration, (PrometheusMetricsSystem) metricsSystem));
      } else {
        return Optional.empty();
      }
    } else if (configuration.getProtocol() == MetricsProtocol.OPENTELEMETRY) {
      if (configuration.isEnabled()) {
        return Optional.of(new MetricsOtelPushService((OpenTelemetrySystem) metricsSystem));
      } else {
        return Optional.empty();
      }
    } else {
      return Optional.empty();
    }
  }
Create Metrics Service.

@param configuration the configuration
@param metricsSystem the metrics system
@return the optional Metrics Service
metrics/core/src/main/java/org/hyperledger/besu/metrics/MetricsService.java