Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public final class OtlpStdoutLogRecordExporterComponentProvider
implements ComponentProvider<LogRecordExporter> {
public final class OtlpStdoutLogRecordExporterComponentProvider implements ComponentProvider {

@Override
public Class<LogRecordExporter> getType() {
public Class<?> getType() {
return LogRecordExporter.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public final class OtlpStdoutMetricExporterComponentProvider
implements ComponentProvider<MetricExporter> {
public final class OtlpStdoutMetricExporterComponentProvider implements ComponentProvider {

@Override
public Class<MetricExporter> getType() {
public Class<?> getType() {
return MetricExporter.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public final class OtlpStdoutSpanExporterComponentProvider
implements ComponentProvider<SpanExporter> {
public final class OtlpStdoutSpanExporterComponentProvider implements ComponentProvider {

@Override
public Class<SpanExporter> getType() {
public Class<?> getType() {
return SpanExporter.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ protected T exporterFromComponentProvider(DeclarativeConfigProperties properties
properties.getComponentLoader().load(ComponentProvider.class).spliterator(), false)
.filter(
p -> {
ComponentProvider<?> c = p;
ComponentProvider c = p;
return "otlp_file/development".equals(c.getName())
&& c.getType().equals(componentProviderType);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public final class ConsoleLogRecordExporterComponentProvider
implements ComponentProvider<LogRecordExporter> {
public final class ConsoleLogRecordExporterComponentProvider implements ComponentProvider {

@Override
public Class<LogRecordExporter> getType() {
public Class<?> getType() {
return LogRecordExporter.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public final class ConsoleMetricExporterComponentProvider
implements ComponentProvider<MetricExporter> {
public final class ConsoleMetricExporterComponentProvider implements ComponentProvider {

@Override
public Class<MetricExporter> getType() {
public Class<?> getType() {
return MetricExporter.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public final class ConsoleSpanExporterComponentProvider implements ComponentProvider<SpanExporter> {
public final class ConsoleSpanExporterComponentProvider implements ComponentProvider {

@Override
public Class<SpanExporter> getType() {
public Class<?> getType() {
return SpanExporter.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public class OtlpGrpcLogRecordExporterComponentProvider
implements ComponentProvider<LogRecordExporter> {
public class OtlpGrpcLogRecordExporterComponentProvider implements ComponentProvider {

@Override
public Class<LogRecordExporter> getType() {
public Class<?> getType() {
return LogRecordExporter.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public class OtlpGrpcMetricExporterComponentProvider implements ComponentProvider<MetricExporter> {
public class OtlpGrpcMetricExporterComponentProvider implements ComponentProvider {

@Override
public Class<MetricExporter> getType() {
public Class<?> getType() {
return MetricExporter.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public class OtlpGrpcSpanExporterComponentProvider implements ComponentProvider<SpanExporter> {
public class OtlpGrpcSpanExporterComponentProvider implements ComponentProvider {

@Override
public Class<SpanExporter> getType() {
public Class<?> getType() {
return SpanExporter.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public class OtlpHttpLogRecordExporterComponentProvider
implements ComponentProvider<LogRecordExporter> {
public class OtlpHttpLogRecordExporterComponentProvider implements ComponentProvider {

@Override
public Class<LogRecordExporter> getType() {
public Class<?> getType() {
return LogRecordExporter.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public class OtlpHttpMetricExporterComponentProvider implements ComponentProvider<MetricExporter> {
public class OtlpHttpMetricExporterComponentProvider implements ComponentProvider {

@Override
public Class<MetricExporter> getType() {
public Class<?> getType() {
return MetricExporter.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public class OtlpHttpSpanExporterComponentProvider implements ComponentProvider<SpanExporter> {
public class OtlpHttpSpanExporterComponentProvider implements ComponentProvider {

@Override
public Class<SpanExporter> getType() {
public Class<?> getType() {
return SpanExporter.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public class PrometheusComponentProvider implements ComponentProvider<MetricReader> {
public class PrometheusComponentProvider implements ComponentProvider {

@Override
public Class<MetricReader> getType() {
public Class<?> getType() {
return MetricReader.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public class ZipkinSpanExporterComponentProvider implements ComponentProvider<SpanExporter> {
public class ZipkinSpanExporterComponentProvider implements ComponentProvider {
@Override
public Class<SpanExporter> getType() {
public Class<?> getType() {
return SpanExporter.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public final class B3ComponentProvider implements ComponentProvider<TextMapPropagator> {
public final class B3ComponentProvider implements ComponentProvider {

@Override
public Class<TextMapPropagator> getType() {
public Class<?> getType() {
return TextMapPropagator.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public final class B3MultiComponentProvider implements ComponentProvider<TextMapPropagator> {
public final class B3MultiComponentProvider implements ComponentProvider {

@Override
public Class<TextMapPropagator> getType() {
public Class<?> getType() {
return TextMapPropagator.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public final class JaegerComponentProvider implements ComponentProvider<TextMapPropagator> {
public final class JaegerComponentProvider implements ComponentProvider {

@Override
public Class<TextMapPropagator> getType() {
public Class<?> getType() {
return TextMapPropagator.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*/
public final class OtTraceComponentProvider implements ComponentProvider<TextMapPropagator> {
public final class OtTraceComponentProvider implements ComponentProvider {

@Override
public Class<TextMapPropagator> getType() {
public Class<?> getType() {
return TextMapPropagator.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change
* at any time.
*
* @param <T> the type of the SDK extension component. See {@link #getType()}. Supported values
* include: {@link SpanExporter}, {@link MetricExporter}, {@link LogRecordExporter}, {@link
* SpanProcessor}, {@link LogRecordProcessor}, {@link TextMapPropagator}, {@link Sampler},
* {@link Resource}.
* <p>Supported component types include: {@link SpanExporter}, {@link MetricExporter}, {@link
* LogRecordExporter}, {@link SpanProcessor}, {@link LogRecordProcessor}, {@link TextMapPropagator},
* {@link Sampler}, {@link Resource}.
*/
public interface ComponentProvider<T> {
public interface ComponentProvider {

/**
* The type of SDK extension component. For example, if providing instances of a custom span
* exporter, the type would be {@link SpanExporter}.
*/
Class<T> getType();
Class<?> getType();

/**
* The name of the exporter, to be referenced in configuration files. For example, if providing
Expand All @@ -59,5 +58,5 @@ public interface ComponentProvider<T> {
*/
// TODO (jack-berg): consider dynamic configuration use case before stabilizing in case that
// affects any API decisions
T create(DeclarativeConfigProperties config);
Object create(DeclarativeConfigProperties config);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/** Declarative configuration context and state carrier. */
Expand Down Expand Up @@ -54,11 +53,8 @@ <T> T loadComponent(Class<T> type, String name, Object model) {

// TODO(jack-berg): cache loaded component providers
List<ComponentProvider> componentProviders = spiHelper.load(ComponentProvider.class);
List<ComponentProvider<?>> matchedProviders =
List<ComponentProvider> matchedProviders =
componentProviders.stream()
.map(
(Function<ComponentProvider, ComponentProvider<?>>)
componentProvider -> componentProvider)
.filter(
componentProvider ->
componentProvider.getType() == type && name.equals(componentProvider.getName()))
Expand All @@ -79,10 +75,10 @@ <T> T loadComponent(Class<T> type, String name, Object model) {
.collect(Collectors.joining(",", "[", "]")));
}
// Exactly one matching component provider
ComponentProvider<T> provider = (ComponentProvider<T>) matchedProviders.get(0);
ComponentProvider provider = matchedProviders.get(0);

try {
return provider.create(config);
return (T) provider.create(config);
} catch (Throwable throwable) {
throw new DeclarativeConfigException(
"Error configuring " + type.getName() + " with name \"" + name + "\"", throwable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.Collections;
import java.util.UUID;

public class ServiceResourceDetector implements ComponentProvider<Resource> {
public class ServiceResourceDetector implements ComponentProvider {

private static final AttributeKey<String> SERVICE_NAME = AttributeKey.stringKey("service.name");
private static final AttributeKey<String> SERVICE_INSTANCE_ID =
Expand All @@ -25,7 +25,7 @@ public class ServiceResourceDetector implements ComponentProvider<Resource> {
private static final String RANDOM_SERVICE_INSTANCE_ID = UUID.randomUUID().toString();

@Override
public Class<Resource> getType() {
public Class<?> getType() {
return Resource.class;
}

Expand Down
Loading
Loading