code: public MetricsFactory resolve() {
          for (MetricsFactoryService metricsFactoryService : serviceLoader) {
              MetricsFactory metricsFactory = metricsFactoryService.load();
              if (metricsFactory != null) {
                  return metricsFactory;
              }
          }
          throw new IllegalStateException("No MetricsFactory could be loaded!");
      }
docs: Resolve MetricsFactory from the Service Provider Interface configuration
  
  @return MetricsFactory