Skip to content

Commit

Permalink
remove ConfigurableProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger committed Feb 28, 2024
1 parent 58e1111 commit 9eefc50
Showing 1 changed file with 1 addition and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@

package io.opentelemetry.instrumentation.spring.autoconfigure.internal;

import io.opentelemetry.sdk.autoconfigure.ComponentLoader;
import io.opentelemetry.sdk.autoconfigure.internal.ComponentLoader;
import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurableProvider;
import io.opentelemetry.sdk.autoconfigure.spi.Ordered;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.context.ApplicationContext;

Expand Down Expand Up @@ -54,23 +51,4 @@ public <T extends Ordered> List<T> loadOrdered(Class<T> spiClass) {
result.addAll(beans);
return result;
}

@Override
public <T extends ConfigurableProvider> Map<String, T> loadConfigurableProviders(
Class<T> spiClass) {
Map<String, T> components = new HashMap<>();
addComponents(components, spiHelper.load(spiClass));
// beans have a higher priority than spi and overwrite values with the same name
addComponents(
components,
applicationContext.getBeanProvider(spiClass).orderedStream().collect(Collectors.toList()));
return components;
}

private static <T> void addComponents(Map<String, T> target, List<T> components) {
for (T component : components) {
String name = ((ConfigurableProvider) component).getName();
target.put(name, component);
}
}
}

0 comments on commit 9eefc50

Please sign in to comment.