Repository: open-telemetry/opentelemetry-java
File: sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/OpenTelemetryConfigurationFactory.java (Java)

Code before:
import io.opentelemetry.sdk.extension.incubator.ExtendedOpenTelemetrySdk;
import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.OpenTelemetryConfigurationModel;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.resources.Resource;
import java.util.Objects;
import java.util.regex.Pattern;

final class OpenTelemetryConfigurationFactory
    implements Factory<OpenTelemetryConfigurationModel, ExtendedOpenTelemetrySdk> {

  private static final Pattern SUPPORTED_FILE_FORMATS = Pattern.compile("^(0.4)|(1.0(-rc.\\d*)?)$");

  private static final OpenTelemetryConfigurationFactory INSTANCE =
      new OpenTelemetryConfigurationFactory();

  private OpenTelemetryConfigurationFactory() {}

  static OpenTelemetryConfigurationFactory getInstance() {
    return INSTANCE;
  }

  @Override
  public ExtendedOpenTelemetrySdk create(
      OpenTelemetryConfigurationModel model, DeclarativeConfigContext context) {
    SdkConfigProvider sdkConfigProvider = SdkConfigProvider.create(model);
    OpenTelemetrySdkBuilder builder = OpenTelemetrySdk.builder();
    String fileFormat = model.getFileFormat();
    if (fileFormat == null || !SUPPORTED_FILE_FORMATS.matcher(fileFormat).matches()) {
      throw new DeclarativeConfigException(
          "Unsupported file format '" + fileFormat + "'. Supported formats include 0.4, 1.0*");
    }
    // TODO(jack-berg): log warning if version is not exact match, which may result in unexpected
    // behavior for experimental properties.

    if (Objects.equals(true, model.getDisabled())) {
      return ExtendedOpenTelemetrySdk.create(builder.build(), sdkConfigProvider);
    }

    if (model.getPropagator() != null) {
      builder.setPropagators(
          PropagatorFactory.getInstance().create(model.getPropagator(), context));
    }

    Resource resource = Resource.getDefault();
    if (model.getResource() != null) {
      resource = ResourceFactory.getInstance().create(model.getResource(), context);
    }
    context.setResource(resource);

    if (model.getMeterProvider() != null) {
      SdkMeterProvider meterProvider =

Review comment (bug):
This was a bug! The `SdkConfigProvider` instance was not being created with the component loader specified in `DeclarativeConfigContext`. 

Code after:
import io.opentelemetry.sdk.extension.incubator.ExtendedOpenTelemetrySdk;
import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.OpenTelemetryConfigurationModel;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.resources.Resource;
import java.util.Objects;
import java.util.regex.Pattern;

final class OpenTelemetryConfigurationFactory
    implements Factory<OpenTelemetryConfigurationModel, ExtendedOpenTelemetrySdk> {

  private static final Pattern SUPPORTED_FILE_FORMATS = Pattern.compile("^(0.4)|(1.0(-rc.\\d*)?)$");

  private static final OpenTelemetryConfigurationFactory INSTANCE =
      new OpenTelemetryConfigurationFactory();

  private OpenTelemetryConfigurationFactory() {}

  static OpenTelemetryConfigurationFactory getInstance() {
    return INSTANCE;
  }

  @Override
  public ExtendedOpenTelemetrySdk create(
      OpenTelemetryConfigurationModel model, DeclarativeConfigContext context) {
    SdkConfigProvider sdkConfigProvider =
        SdkConfigProvider.create(model, context.getSpiHelper().getComponentLoader());
    OpenTelemetrySdkBuilder builder = OpenTelemetrySdk.builder();
    String fileFormat = model.getFileFormat();
    if (fileFormat == null || !SUPPORTED_FILE_FORMATS.matcher(fileFormat).matches()) {
      throw new DeclarativeConfigException(
          "Unsupported file format '" + fileFormat + "'. Supported formats include 0.4, 1.0*");
    }
    // TODO(jack-berg): log warning if version is not exact match, which may result in unexpected
    // behavior for experimental properties.

    if (Objects.equals(true, model.getDisabled())) {
      return ExtendedOpenTelemetrySdk.create(builder.build(), sdkConfigProvider);
    }

    if (model.getPropagator() != null) {
      builder.setPropagators(
          PropagatorFactory.getInstance().create(model.getPropagator(), context));
    }

    Resource resource = Resource.getDefault();
    if (model.getResource() != null) {
      resource = ResourceFactory.getInstance().create(model.getResource(), context);
    }
    context.setResource(resource);

    if (model.getMeterProvider() != null) {