diff --git a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/FileConfigurationTest.java b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/FileConfigurationTest.java index f9234de4c65..c49208aa917 100644 --- a/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/FileConfigurationTest.java +++ b/sdk-extensions/autoconfigure/src/testFullConfig/java/io/opentelemetry/sdk/autoconfigure/FileConfigurationTest.java @@ -17,11 +17,7 @@ import io.github.netmikey.logunit.api.LogCapturer; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.api.baggage.propagation.W3CBaggagePropagator; import io.opentelemetry.api.incubator.events.GlobalEventLoggerProvider; -import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator; -import io.opentelemetry.context.propagation.ContextPropagators; -import io.opentelemetry.context.propagation.TextMapPropagator; import io.opentelemetry.exporter.logging.LoggingSpanExporter; import io.opentelemetry.internal.testing.CleanupExtension; import io.opentelemetry.sdk.OpenTelemetrySdk; @@ -91,11 +87,6 @@ void configFile_Valid() { Resource.getDefault().toBuilder().put("service.name", "test").build()) .addSpanProcessor(SimpleSpanProcessor.create(LoggingSpanExporter.create())) .build()) - .setPropagators( - ContextPropagators.create( - TextMapPropagator.composite( - W3CTraceContextPropagator.getInstance(), - W3CBaggagePropagator.getInstance()))) .build(); cleanup.addCloseable(expectedSdk); AutoConfiguredOpenTelemetrySdkBuilder builder = spy(AutoConfiguredOpenTelemetrySdk.builder()); diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AggregationFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AggregationFactory.java index 726177d65a6..45feb74c8cc 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AggregationFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AggregationFactory.java @@ -12,7 +12,6 @@ import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.ExplicitBucketHistogram; import java.io.Closeable; import java.util.List; -import javax.annotation.Nullable; final class AggregationFactory implements Factory { @@ -27,11 +26,7 @@ static AggregationFactory getInstance() { @Override public io.opentelemetry.sdk.metrics.Aggregation create( - @Nullable Aggregation model, SpiHelper spiHelper, List closeables) { - if (model == null) { - return io.opentelemetry.sdk.metrics.Aggregation.defaultAggregation(); - } - + Aggregation model, SpiHelper spiHelper, List closeables) { if (model.getDrop() != null) { return io.opentelemetry.sdk.metrics.Aggregation.drop(); } diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AttributesFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AttributesFactory.java index 22a9273cd8f..70cd2e186ae 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AttributesFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AttributesFactory.java @@ -14,7 +14,6 @@ import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Attributes; import java.io.Closeable; import java.util.List; -import javax.annotation.Nullable; final class AttributesFactory implements Factory { @@ -29,11 +28,7 @@ static AttributesFactory getInstance() { @Override public io.opentelemetry.api.common.Attributes create( - @Nullable Attributes model, SpiHelper spiHelper, List closeables) { - if (model == null) { - return io.opentelemetry.api.common.Attributes.empty(); - } - + Attributes model, SpiHelper spiHelper, List closeables) { AttributesBuilder builder = io.opentelemetry.api.common.Attributes.builder(); String serviceName = model.getServiceName(); diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/Factory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/Factory.java index 609fcd4f902..c5f5e7c59d3 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/Factory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/Factory.java @@ -8,7 +8,6 @@ import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper; import java.io.Closeable; import java.util.List; -import javax.annotation.Nullable; interface Factory { @@ -20,5 +19,5 @@ interface Factory { * @param closeables mutable list of closeables created * @return the {@link ResultT} */ - ResultT create(@Nullable ModelT model, SpiHelper spiHelper, List closeables); + ResultT create(ModelT model, SpiHelper spiHelper, List closeables); } diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/FileConfigUtil.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/FileConfigUtil.java index 4dfdcbd5565..75fd08858a7 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/FileConfigUtil.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/FileConfigUtil.java @@ -32,6 +32,13 @@ static T assertNotNull(@Nullable T object, String description) { return object; } + static T requireNonNull(@Nullable T object, String description) { + if (object == null) { + throw new ConfigurationException(description + " is required but is null"); + } + return object; + } + /** * Find a registered {@link ComponentProvider} which {@link ComponentProvider#getType()} matching * {@code type}, {@link ComponentProvider#getName()} matching {@code name}, and call {@link diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/InstrumentSelectorFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/InstrumentSelectorFactory.java index ec117228b64..f89a94ea507 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/InstrumentSelectorFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/InstrumentSelectorFactory.java @@ -13,7 +13,6 @@ import io.opentelemetry.sdk.metrics.InstrumentType; import java.io.Closeable; import java.util.List; -import javax.annotation.Nullable; final class InstrumentSelectorFactory implements Factory { @@ -27,11 +26,7 @@ static InstrumentSelectorFactory getInstance() { @Override public InstrumentSelector create( - @Nullable Selector model, SpiHelper spiHelper, List closeables) { - if (model == null) { - throw new ConfigurationException("selector must not be null"); - } - + Selector model, SpiHelper spiHelper, List closeables) { InstrumentSelectorBuilder builder = InstrumentSelector.builder(); if (model.getInstrumentName() != null) { builder.setName(model.getInstrumentName()); diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogLimitsFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogLimitsFactory.java index d4a7dea5c16..765fdd5100e 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogLimitsFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogLimitsFactory.java @@ -12,7 +12,6 @@ import io.opentelemetry.sdk.logs.LogLimitsBuilder; import java.io.Closeable; import java.util.List; -import javax.annotation.Nullable; final class LogLimitsFactory implements Factory { @@ -26,12 +25,7 @@ static LogLimitsFactory getInstance() { @Override public LogLimits create( - @Nullable LogRecordLimitsAndAttributeLimits model, - SpiHelper spiHelper, - List closeables) { - if (model == null) { - return LogLimits.getDefault(); - } + LogRecordLimitsAndAttributeLimits model, SpiHelper spiHelper, List closeables) { LogLimitsBuilder builder = LogLimits.builder(); AttributeLimits attributeLimitsModel = model.getAttributeLimits(); diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordExporterFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordExporterFactory.java index f930c2846ef..58ce105eddd 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordExporterFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordExporterFactory.java @@ -14,7 +14,6 @@ import java.io.Closeable; import java.util.List; import java.util.Map; -import javax.annotation.Nullable; final class LogRecordExporterFactory implements Factory< @@ -29,19 +28,11 @@ static LogRecordExporterFactory getInstance() { return INSTANCE; } - @SuppressWarnings("NullAway") // Override superclass non-null response @Override - @Nullable public LogRecordExporter create( - @Nullable - io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.LogRecordExporter - model, + io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.LogRecordExporter model, SpiHelper spiHelper, List closeables) { - if (model == null) { - return null; - } - Otlp otlpModel = model.getOtlp(); if (otlpModel != null) { model.getAdditionalProperties().put("otlp", otlpModel); @@ -67,8 +58,8 @@ public LogRecordExporter create( exporterKeyValue.getKey(), exporterKeyValue.getValue()); return FileConfigUtil.addAndReturn(closeables, logRecordExporter); + } else { + throw new ConfigurationException("log exporter must be set"); } - - return null; } } diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordProcessorFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordProcessorFactory.java index aaf472beec7..78183f19232 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordProcessorFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordProcessorFactory.java @@ -17,7 +17,6 @@ import java.io.Closeable; import java.time.Duration; import java.util.List; -import javax.annotation.Nullable; final class LogRecordProcessorFactory implements Factory< @@ -34,24 +33,18 @@ static LogRecordProcessorFactory getInstance() { @Override public LogRecordProcessor create( - @Nullable - io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.LogRecordProcessor - model, + io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.LogRecordProcessor model, SpiHelper spiHelper, List closeables) { - if (model == null) { - return LogRecordProcessor.composite(); - } - io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.BatchLogRecordProcessor batchModel = model.getBatch(); if (batchModel != null) { - LogRecordExporter exporterModel = batchModel.getExporter(); + LogRecordExporter exporterModel = + FileConfigUtil.requireNonNull( + batchModel.getExporter(), "batch log record processor exporter"); + io.opentelemetry.sdk.logs.export.LogRecordExporter logRecordExporter = LogRecordExporterFactory.getInstance().create(exporterModel, spiHelper, closeables); - if (logRecordExporter == null) { - throw new ConfigurationException("exporter required for batch log record processor"); - } BatchLogRecordProcessorBuilder builder = BatchLogRecordProcessor.builder(logRecordExporter); if (batchModel.getExportTimeout() != null) { builder.setExporterTimeout(Duration.ofMillis(batchModel.getExportTimeout())); @@ -71,12 +64,11 @@ public LogRecordProcessor create( io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.SimpleLogRecordProcessor simpleModel = model.getSimple(); if (simpleModel != null) { - LogRecordExporter exporterModel = simpleModel.getExporter(); + LogRecordExporter exporterModel = + FileConfigUtil.requireNonNull( + simpleModel.getExporter(), "simple log record processor exporter"); io.opentelemetry.sdk.logs.export.LogRecordExporter logRecordExporter = LogRecordExporterFactory.getInstance().create(exporterModel, spiHelper, closeables); - if (logRecordExporter == null) { - throw new ConfigurationException("exporter required for simple log record processor"); - } return FileConfigUtil.addAndReturn( closeables, SimpleLogRecordProcessor.create(logRecordExporter)); } @@ -86,8 +78,8 @@ public LogRecordProcessor create( throw new ConfigurationException( "Unrecognized log record processor(s): " + model.getAdditionalProperties().keySet().stream().collect(joining(",", "[", "]"))); + } else { + throw new ConfigurationException("log processor must be set"); } - - return LogRecordProcessor.composite(); } } diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LoggerProviderFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LoggerProviderFactory.java index 36bbce54566..3d46098ae9e 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LoggerProviderFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LoggerProviderFactory.java @@ -13,7 +13,6 @@ import io.opentelemetry.sdk.logs.SdkLoggerProviderBuilder; import java.io.Closeable; import java.util.List; -import javax.annotation.Nullable; final class LoggerProviderFactory implements Factory { @@ -28,13 +27,9 @@ static LoggerProviderFactory getInstance() { @Override public SdkLoggerProviderBuilder create( - @Nullable LoggerProviderAndAttributeLimits model, - SpiHelper spiHelper, - List closeables) { + LoggerProviderAndAttributeLimits model, SpiHelper spiHelper, List closeables) { SdkLoggerProviderBuilder builder = SdkLoggerProvider.builder(); - if (model == null) { - return builder; - } + LoggerProvider loggerProviderModel = model.getLoggerProvider(); if (loggerProviderModel == null) { return builder; diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MeterProviderFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MeterProviderFactory.java index 0acb6c703f0..c675920a797 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MeterProviderFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MeterProviderFactory.java @@ -5,15 +5,18 @@ package io.opentelemetry.sdk.extension.incubator.fileconfig; +import static io.opentelemetry.sdk.extension.incubator.fileconfig.FileConfigUtil.requireNonNull; + import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper; import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.MeterProvider; import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.MetricReader; +import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Selector; +import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Stream; import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.View; import io.opentelemetry.sdk.metrics.SdkMeterProvider; import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder; import java.io.Closeable; import java.util.List; -import javax.annotation.Nullable; final class MeterProviderFactory implements Factory { @@ -27,11 +30,7 @@ static MeterProviderFactory getInstance() { @Override public SdkMeterProviderBuilder create( - @Nullable MeterProvider model, SpiHelper spiHelper, List closeables) { - if (model == null) { - return SdkMeterProvider.builder(); - } - + MeterProvider model, SpiHelper spiHelper, List closeables) { SdkMeterProviderBuilder builder = SdkMeterProvider.builder(); List readerModels = model.getReaders(); @@ -49,11 +48,13 @@ public SdkMeterProviderBuilder create( List viewModels = model.getViews(); if (viewModels != null) { viewModels.forEach( - viewModel -> - builder.registerView( - InstrumentSelectorFactory.getInstance() - .create(viewModel.getSelector(), spiHelper, closeables), - ViewFactory.getInstance().create(viewModel.getStream(), spiHelper, closeables))); + viewModel -> { + Selector selector = requireNonNull(viewModel.getSelector(), "view selector"); + Stream stream = requireNonNull(viewModel.getStream(), "view stream"); + builder.registerView( + InstrumentSelectorFactory.getInstance().create(selector, spiHelper, closeables), + ViewFactory.getInstance().create(stream, spiHelper, closeables)); + }); } return builder; diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricExporterFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricExporterFactory.java index 7bba4b843f0..f614761728a 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricExporterFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricExporterFactory.java @@ -14,7 +14,6 @@ import java.io.Closeable; import java.util.List; import java.util.Map; -import javax.annotation.Nullable; final class MetricExporterFactory implements Factory< @@ -29,18 +28,11 @@ static MetricExporterFactory getInstance() { return INSTANCE; } - @SuppressWarnings("NullAway") // Override superclass non-null response @Override - @Nullable public MetricExporter create( - @Nullable - io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.MetricExporter model, + io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.MetricExporter model, SpiHelper spiHelper, List closeables) { - if (model == null) { - return null; - } - OtlpMetric otlpModel = model.getOtlp(); if (otlpModel != null) { model.getAdditionalProperties().put("otlp", otlpModel); @@ -74,8 +66,8 @@ public MetricExporter create( exporterKeyValue.getKey(), exporterKeyValue.getValue()); return FileConfigUtil.addAndReturn(closeables, metricExporter); + } else { + throw new ConfigurationException("metric exporter must be set"); } - - return null; } } diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricReaderFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricReaderFactory.java index 3a049ab2689..00f3dfa17a0 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricReaderFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricReaderFactory.java @@ -5,6 +5,8 @@ package io.opentelemetry.sdk.extension.incubator.fileconfig; +import static io.opentelemetry.sdk.extension.incubator.fileconfig.FileConfigUtil.requireNonNull; + import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper; import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException; import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.MetricExporter; @@ -16,7 +18,6 @@ import java.io.Closeable; import java.time.Duration; import java.util.List; -import javax.annotation.Nullable; final class MetricReaderFactory implements Factory< @@ -31,26 +32,17 @@ static MetricReaderFactory getInstance() { return INSTANCE; } - @SuppressWarnings("NullAway") // Override superclass non-null response @Override - @Nullable public MetricReader create( - @Nullable - io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.MetricReader model, + io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.MetricReader model, SpiHelper spiHelper, List closeables) { - if (model == null) { - return null; - } - PeriodicMetricReader periodicModel = model.getPeriodic(); if (periodicModel != null) { - MetricExporter exporterModel = periodicModel.getExporter(); + MetricExporter exporterModel = + requireNonNull(periodicModel.getExporter(), "periodic metric reader exporter"); io.opentelemetry.sdk.metrics.export.MetricExporter metricExporter = MetricExporterFactory.getInstance().create(exporterModel, spiHelper, closeables); - if (metricExporter == null) { - throw new ConfigurationException("exporter required for periodic reader"); - } PeriodicMetricReaderBuilder builder = io.opentelemetry.sdk.metrics.export.PeriodicMetricReader.builder( FileConfigUtil.addAndReturn(closeables, metricExporter)); @@ -62,10 +54,8 @@ public MetricReader create( PullMetricReader pullModel = model.getPull(); if (pullModel != null) { - MetricExporter exporterModel = pullModel.getExporter(); - if (exporterModel == null) { - throw new ConfigurationException("exporter required for pull reader"); - } + MetricExporter exporterModel = + requireNonNull(pullModel.getExporter(), "pull metric reader exporter"); Prometheus prometheusModel = exporterModel.getPrometheus(); if (prometheusModel != null) { MetricReader metricReader = @@ -77,6 +67,6 @@ public MetricReader create( throw new ConfigurationException("prometheus is the only currently supported pull reader"); } - return null; + throw new ConfigurationException("reader must be set"); } } diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/OpenTelemetryConfigurationFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/OpenTelemetryConfigurationFactory.java index cb2b52a8472..1677361d8ae 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/OpenTelemetryConfigurationFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/OpenTelemetryConfigurationFactory.java @@ -14,7 +14,6 @@ import java.io.Closeable; import java.util.List; import java.util.Objects; -import javax.annotation.Nullable; final class OpenTelemetryConfigurationFactory implements Factory { @@ -30,12 +29,8 @@ static OpenTelemetryConfigurationFactory getInstance() { @Override public OpenTelemetrySdk create( - @Nullable OpenTelemetryConfiguration model, SpiHelper spiHelper, List closeables) { + OpenTelemetryConfiguration model, SpiHelper spiHelper, List closeables) { OpenTelemetrySdkBuilder builder = OpenTelemetrySdk.builder(); - if (model == null) { - return FileConfigUtil.addAndReturn(closeables, builder.build()); - } - if (!"0.1".equals(model.getFileFormat())) { throw new ConfigurationException("Unsupported file format. Supported formats include: 0.1"); } @@ -44,11 +39,15 @@ public OpenTelemetrySdk create( return builder.build(); } - builder.setPropagators( - PropagatorFactory.getInstance().create(model.getPropagator(), spiHelper, closeables)); + if (model.getPropagator() != null) { + builder.setPropagators( + PropagatorFactory.getInstance().create(model.getPropagator(), spiHelper, closeables)); + } - Resource resource = - ResourceFactory.getInstance().create(model.getResource(), spiHelper, closeables); + Resource resource = Resource.getDefault(); + if (model.getResource() != null) { + resource = ResourceFactory.getInstance().create(model.getResource(), spiHelper, closeables); + } if (model.getLoggerProvider() != null) { builder.setLoggerProvider( diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/PropagatorFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/PropagatorFactory.java index d53c3beda76..d9572fd8406 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/PropagatorFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/PropagatorFactory.java @@ -5,13 +5,14 @@ package io.opentelemetry.sdk.extension.incubator.fileconfig; +import static io.opentelemetry.sdk.extension.incubator.fileconfig.FileConfigUtil.requireNonNull; + import io.opentelemetry.context.propagation.ContextPropagators; import io.opentelemetry.context.propagation.TextMapPropagator; import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper; import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Propagator; import java.io.Closeable; import java.util.List; -import javax.annotation.Nullable; final class PropagatorFactory implements Factory { @@ -25,11 +26,8 @@ static PropagatorFactory getInstance() { @Override public ContextPropagators create( - @Nullable Propagator model, SpiHelper spiHelper, List closeables) { - List compositeModel = null; - if (model != null) { - compositeModel = model.getComposite(); - } + Propagator model, SpiHelper spiHelper, List closeables) { + List compositeModel = requireNonNull(model.getComposite(), "composite propagator"); TextMapPropagator textMapPropagator = TextMapPropagatorFactory.getInstance().create(compositeModel, spiHelper, closeables); return ContextPropagators.create(textMapPropagator); diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ResourceFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ResourceFactory.java index 47ec3b6606a..04a0de2bcac 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ResourceFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ResourceFactory.java @@ -11,7 +11,6 @@ import io.opentelemetry.sdk.resources.ResourceBuilder; import java.io.Closeable; import java.util.List; -import javax.annotation.Nullable; final class ResourceFactory implements Factory { @@ -25,11 +24,7 @@ static ResourceFactory getInstance() { @Override public io.opentelemetry.sdk.resources.Resource create( - @Nullable Resource model, SpiHelper spiHelper, List closeables) { - if (model == null) { - return io.opentelemetry.sdk.resources.Resource.getDefault(); - } - + Resource model, SpiHelper spiHelper, List closeables) { ResourceBuilder builder = io.opentelemetry.sdk.resources.Resource.getDefault().toBuilder(); Attributes attributesModel = model.getAttributes(); diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SamplerFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SamplerFactory.java index 8d881c2d03e..f900015f8c4 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SamplerFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SamplerFactory.java @@ -23,7 +23,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.annotation.Nullable; final class SamplerFactory implements Factory< @@ -39,13 +38,9 @@ static SamplerFactory getInstance() { @Override public Sampler create( - @Nullable io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Sampler model, + io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Sampler model, SpiHelper spiHelper, List closeables) { - if (model == null) { - return Sampler.parentBased(Sampler.alwaysOn()); - } - if (model.getAlwaysOn() != null) { return Sampler.alwaysOn(); } @@ -121,9 +116,9 @@ public Sampler create( throw new ConfigurationException( "Unrecognized sampler(s): " + model.getAdditionalProperties().keySet().stream().collect(joining(",", "[", "]"))); + } else { + throw new ConfigurationException("sampler must be set"); } - - return Sampler.parentBased(Sampler.alwaysOn()); } private static NamedSpiManager samplerSpiManager( diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanExporterFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanExporterFactory.java index cf2c866bc3c..a48af93fb75 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanExporterFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanExporterFactory.java @@ -15,7 +15,6 @@ import java.io.Closeable; import java.util.List; import java.util.Map; -import javax.annotation.Nullable; final class SpanExporterFactory implements Factory< @@ -30,18 +29,11 @@ static SpanExporterFactory getInstance() { return INSTANCE; } - @SuppressWarnings("NullAway") // Override superclass non-null response @Override - @Nullable public SpanExporter create( - @Nullable - io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.SpanExporter model, + io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.SpanExporter model, SpiHelper spiHelper, List closeables) { - if (model == null) { - return null; - } - Otlp otlpModel = model.getOtlp(); if (otlpModel != null) { model.getAdditionalProperties().put("otlp", otlpModel); @@ -76,8 +68,8 @@ public SpanExporter create( exporterKeyValue.getKey(), exporterKeyValue.getValue()); return FileConfigUtil.addAndReturn(closeables, spanExporter); + } else { + throw new ConfigurationException("span exporter must be set"); } - - return null; } } diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanLimitsFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanLimitsFactory.java index ef03ad70ca8..b3e83b7a2ba 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanLimitsFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanLimitsFactory.java @@ -11,7 +11,6 @@ import io.opentelemetry.sdk.trace.SpanLimitsBuilder; import java.io.Closeable; import java.util.List; -import javax.annotation.Nullable; final class SpanLimitsFactory implements Factory { @@ -26,13 +25,7 @@ static SpanLimitsFactory getInstance() { @Override public io.opentelemetry.sdk.trace.SpanLimits create( - @Nullable SpanLimitsAndAttributeLimits model, - SpiHelper spiHelper, - List closeables) { - if (model == null) { - return io.opentelemetry.sdk.trace.SpanLimits.getDefault(); - } - + SpanLimitsAndAttributeLimits model, SpiHelper spiHelper, List closeables) { SpanLimitsBuilder builder = io.opentelemetry.sdk.trace.SpanLimits.builder(); AttributeLimits attributeLimitsModel = model.getAttributeLimits(); diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanProcessorFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanProcessorFactory.java index 6536f0bf3ca..d0c50ebaa61 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanProcessorFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanProcessorFactory.java @@ -17,7 +17,6 @@ import java.io.Closeable; import java.time.Duration; import java.util.List; -import javax.annotation.Nullable; final class SpanProcessorFactory implements Factory< @@ -34,23 +33,16 @@ static SpanProcessorFactory getInstance() { @Override public SpanProcessor create( - @Nullable - io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.SpanProcessor model, + io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.SpanProcessor model, SpiHelper spiHelper, List closeables) { - if (model == null) { - return SpanProcessor.composite(); - } - io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.BatchSpanProcessor batchModel = model.getBatch(); if (batchModel != null) { - SpanExporter exporterModel = batchModel.getExporter(); + SpanExporter exporterModel = + FileConfigUtil.requireNonNull(batchModel.getExporter(), "batch span processor exporter"); io.opentelemetry.sdk.trace.export.SpanExporter spanExporter = SpanExporterFactory.getInstance().create(exporterModel, spiHelper, closeables); - if (spanExporter == null) { - throw new ConfigurationException("exporter required for batch span processor"); - } BatchSpanProcessorBuilder builder = BatchSpanProcessor.builder(spanExporter); if (batchModel.getExportTimeout() != null) { builder.setExporterTimeout(Duration.ofMillis(batchModel.getExportTimeout())); @@ -70,12 +62,11 @@ public SpanProcessor create( io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.SimpleSpanProcessor simpleModel = model.getSimple(); if (simpleModel != null) { - SpanExporter exporterModel = simpleModel.getExporter(); + SpanExporter exporterModel = + FileConfigUtil.requireNonNull( + simpleModel.getExporter(), "simple span processor exporter"); io.opentelemetry.sdk.trace.export.SpanExporter spanExporter = SpanExporterFactory.getInstance().create(exporterModel, spiHelper, closeables); - if (spanExporter == null) { - throw new ConfigurationException("exporter required for simple span processor"); - } return FileConfigUtil.addAndReturn(closeables, SimpleSpanProcessor.create(spanExporter)); } @@ -84,8 +75,8 @@ public SpanProcessor create( throw new ConfigurationException( "Unrecognized span processor(s): " + model.getAdditionalProperties().keySet().stream().collect(joining(",", "[", "]"))); + } else { + throw new ConfigurationException("span processor must be set"); } - - return SpanProcessor.composite(); } } diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TextMapPropagatorFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TextMapPropagatorFactory.java index 4451ac98516..965093d1c6b 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TextMapPropagatorFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TextMapPropagatorFactory.java @@ -19,7 +19,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import javax.annotation.Nullable; final class TextMapPropagatorFactory implements Factory, TextMapPropagator> { @@ -33,8 +32,8 @@ static TextMapPropagatorFactory getInstance() { @Override public TextMapPropagator create( - @Nullable List model, SpiHelper spiHelper, List closeables) { - if (model == null || model.isEmpty()) { + List model, SpiHelper spiHelper, List closeables) { + if (model.isEmpty()) { model = Arrays.asList("tracecontext", "baggage"); } diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TracerProviderFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TracerProviderFactory.java index e5940749b55..ff8000806c7 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TracerProviderFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TracerProviderFactory.java @@ -14,7 +14,6 @@ import io.opentelemetry.sdk.trace.samplers.Sampler; import java.io.Closeable; import java.util.List; -import javax.annotation.Nullable; final class TracerProviderFactory implements Factory { @@ -29,13 +28,8 @@ static TracerProviderFactory getInstance() { @Override public SdkTracerProviderBuilder create( - @Nullable TracerProviderAndAttributeLimits model, - SpiHelper spiHelper, - List closeables) { + TracerProviderAndAttributeLimits model, SpiHelper spiHelper, List closeables) { SdkTracerProviderBuilder builder = SdkTracerProvider.builder(); - if (model == null) { - return builder; - } TracerProvider tracerProviderModel = model.getTracerProvider(); if (tracerProviderModel == null) { return builder; @@ -50,10 +44,12 @@ public SdkTracerProviderBuilder create( closeables); builder.setSpanLimits(spanLimits); - Sampler sampler = - SamplerFactory.getInstance() - .create(tracerProviderModel.getSampler(), spiHelper, closeables); - builder.setSampler(sampler); + if (tracerProviderModel.getSampler() != null) { + Sampler sampler = + SamplerFactory.getInstance() + .create(tracerProviderModel.getSampler(), spiHelper, closeables); + builder.setSampler(sampler); + } List processors = tracerProviderModel.getProcessors(); if (processors != null) { diff --git a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ViewFactory.java b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ViewFactory.java index 77a66833761..cb23d699ecc 100644 --- a/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ViewFactory.java +++ b/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ViewFactory.java @@ -6,14 +6,12 @@ package io.opentelemetry.sdk.extension.incubator.fileconfig; import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper; -import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException; import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Stream; import io.opentelemetry.sdk.metrics.View; import io.opentelemetry.sdk.metrics.ViewBuilder; import java.io.Closeable; import java.util.HashSet; import java.util.List; -import javax.annotation.Nullable; final class ViewFactory implements Factory { @@ -26,11 +24,7 @@ static ViewFactory getInstance() { } @Override - public View create(@Nullable Stream model, SpiHelper spiHelper, List closeables) { - if (model == null) { - throw new ConfigurationException("stream must not be null"); - } - + public View create(Stream model, SpiHelper spiHelper, List closeables) { ViewBuilder builder = View.builder(); if (model.getName() != null) { builder.setName(model.getName()); diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AggregationFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AggregationFactoryTest.java index 1f0c6faf5ca..8e7dafad412 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AggregationFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AggregationFactoryTest.java @@ -17,24 +17,13 @@ import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Sum; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.stream.Stream; -import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; class AggregationFactoryTest { - @Test - void create_Null() { - assertThat( - AggregationFactory.getInstance() - .create(null, mock(SpiHelper.class), Collections.emptyList()) - .toString()) - .isEqualTo(io.opentelemetry.sdk.metrics.Aggregation.defaultAggregation().toString()); - } - @ParameterizedTest @MethodSource("createTestCases") void create(Aggregation model, io.opentelemetry.sdk.metrics.Aggregation expectedResult) { diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AttributesFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AttributesFactoryTest.java index dc32aa6fe28..e50fa61209d 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AttributesFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/AttributesFactoryTest.java @@ -22,14 +22,6 @@ class AttributesFactoryTest { - @Test - void create_Null() { - assertThat( - AttributesFactory.getInstance() - .create(null, mock(SpiHelper.class), Collections.emptyList())) - .isEqualTo(io.opentelemetry.api.common.Attributes.empty()); - } - @ParameterizedTest @MethodSource("invalidAttributes") void create_InvalidAttributes(Attributes model, String expectedMessage) { diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/InstrumentSelectorFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/InstrumentSelectorFactoryTest.java index c10b6394bc4..9b3ada1a6fe 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/InstrumentSelectorFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/InstrumentSelectorFactoryTest.java @@ -19,16 +19,6 @@ class InstrumentSelectorFactoryTest { - @Test - void create_Null() { - assertThatThrownBy( - () -> - InstrumentSelectorFactory.getInstance() - .create(null, mock(SpiHelper.class), Collections.emptyList())) - .isInstanceOf(ConfigurationException.class) - .hasMessage("selector must not be null"); - } - @Test void create_Defaults() { assertThatThrownBy( diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogLimitsFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogLimitsFactoryTest.java index 49a0b337af2..492b8c4b425 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogLimitsFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogLimitsFactoryTest.java @@ -31,7 +31,6 @@ void create(LogRecordLimitsAndAttributeLimits model, LogLimits expectedLogLimits private static Stream createArguments() { return Stream.of( - Arguments.of(null, LogLimits.builder().build()), Arguments.of( LogRecordLimitsAndAttributeLimits.create(null, null), LogLimits.builder().build()), Arguments.of( diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordExporterFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordExporterFactoryTest.java index 7a8815d57ce..a2a6d057139 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordExporterFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordExporterFactoryTest.java @@ -56,12 +56,6 @@ class LogRecordExporterFactoryTest { private SpiHelper spiHelper = SpiHelper.create(LogRecordExporterFactoryTest.class.getClassLoader()); - @Test - void create_Null() { - assertThat(LogRecordExporterFactory.getInstance().create(null, spiHelper, new ArrayList<>())) - .isNull(); - } - @Test void create_OtlpDefaults() { spiHelper = spy(spiHelper); diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordProcessorFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordProcessorFactoryTest.java index 7a9e632d2b3..06ad307ee06 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordProcessorFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LogRecordProcessorFactoryTest.java @@ -33,19 +33,6 @@ class LogRecordProcessorFactoryTest { private final SpiHelper spiHelper = SpiHelper.create(LogRecordProcessorFactoryTest.class.getClassLoader()); - @Test - void create_Null() { - List closeables = new ArrayList<>(); - - io.opentelemetry.sdk.logs.LogRecordProcessor processor = - LogRecordProcessorFactory.getInstance().create(null, spiHelper, Collections.emptyList()); - cleanup.addCloseable(processor); - cleanup.addCloseables(closeables); - - assertThat(processor.toString()) - .isEqualTo(io.opentelemetry.sdk.logs.LogRecordProcessor.composite().toString()); - } - @Test void create_BatchNullExporter() { assertThatThrownBy( @@ -56,7 +43,7 @@ void create_BatchNullExporter() { spiHelper, Collections.emptyList())) .isInstanceOf(ConfigurationException.class) - .hasMessage("exporter required for batch log record processor"); + .hasMessage("batch log record processor exporter is required but is null"); } @Test @@ -123,7 +110,7 @@ void create_SimpleNullExporter() { spiHelper, Collections.emptyList())) .isInstanceOf(ConfigurationException.class) - .hasMessage("exporter required for simple log record processor"); + .hasMessage("simple log record processor exporter is required but is null"); } @Test diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LoggerProviderFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LoggerProviderFactoryTest.java index 4ab9403b425..312c8dc85d4 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LoggerProviderFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/LoggerProviderFactoryTest.java @@ -52,7 +52,6 @@ void create(LoggerProviderAndAttributeLimits model, SdkLoggerProvider expectedPr private static Stream createArguments() { return Stream.of( - Arguments.of(null, SdkLoggerProvider.builder().build()), Arguments.of( LoggerProviderAndAttributeLimits.create(null, null), SdkLoggerProvider.builder().build()), diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MeterProviderFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MeterProviderFactoryTest.java index bdcc24626a7..b2ac1d838d0 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MeterProviderFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MeterProviderFactoryTest.java @@ -34,20 +34,6 @@ class MeterProviderFactoryTest { private final SpiHelper spiHelper = SpiHelper.create(MeterProviderFactoryTest.class.getClassLoader()); - @Test - void create_Null() { - List closeables = new ArrayList<>(); - SdkMeterProvider expectedProvider = SdkMeterProvider.builder().build(); - cleanup.addCloseable(expectedProvider); - - SdkMeterProvider provider = - MeterProviderFactory.getInstance().create(null, spiHelper, closeables).build(); - cleanup.addCloseable(provider); - cleanup.addCloseables(closeables); - - assertThat(provider.toString()).isEqualTo(expectedProvider.toString()); - } - @Test void create_Defaults() { List closeables = new ArrayList<>(); diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricExporterFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricExporterFactoryTest.java index dd8cca69107..8356339e063 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricExporterFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricExporterFactoryTest.java @@ -63,12 +63,6 @@ class MetricExporterFactoryTest { private SpiHelper spiHelper = SpiHelper.create(MetricExporterFactoryTest.class.getClassLoader()); - @Test - void create_Null() { - assertThat(MetricExporterFactory.getInstance().create(null, spiHelper, new ArrayList<>())) - .isNull(); - } - @Test void create_OtlpDefaults() { spiHelper = spy(spiHelper); diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricReaderFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricReaderFactoryTest.java index 3bd03e33c8d..22a7d36106d 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricReaderFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/MetricReaderFactoryTest.java @@ -43,12 +43,6 @@ class MetricReaderFactoryTest { private SpiHelper spiHelper = SpiHelper.create(MetricReaderFactoryTest.class.getClassLoader()); - @Test - void create_Null() { - assertThat(MetricReaderFactory.getInstance().create(null, spiHelper, Collections.emptyList())) - .isNull(); - } - @Test void create_PeriodicNullExporter() { assertThatThrownBy( @@ -59,7 +53,7 @@ void create_PeriodicNullExporter() { spiHelper, Collections.emptyList())) .isInstanceOf(ConfigurationException.class) - .hasMessage("exporter required for periodic reader"); + .hasMessage("periodic metric reader exporter is required but is null"); } @Test @@ -181,7 +175,7 @@ void create_InvalidPullReader() { spiHelper, Collections.emptyList())) .isInstanceOf(ConfigurationException.class) - .hasMessage("exporter required for pull reader"); + .hasMessage("pull metric reader exporter is required but is null"); assertThatThrownBy( () -> diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/OpenTelemetryConfigurationFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/OpenTelemetryConfigurationFactoryTest.java index ac249c94b9a..da3cc7cd013 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/OpenTelemetryConfigurationFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/OpenTelemetryConfigurationFactoryTest.java @@ -69,20 +69,6 @@ class OpenTelemetryConfigurationFactoryTest { private final SpiHelper spiHelper = SpiHelper.create(OpenTelemetryConfigurationFactoryTest.class.getClassLoader()); - @Test - void create_Null() { - List closeables = new ArrayList<>(); - OpenTelemetrySdk expectedSdk = OpenTelemetrySdk.builder().build(); - cleanup.addCloseable(expectedSdk); - - OpenTelemetrySdk sdk = - OpenTelemetryConfigurationFactory.getInstance().create(null, spiHelper, closeables); - cleanup.addCloseable(sdk); - cleanup.addCloseables(closeables); - - assertThat(sdk.toString()).isEqualTo(expectedSdk.toString()); - } - @Test void create_InvalidFileFormat() { List testCases = @@ -104,14 +90,7 @@ void create_InvalidFileFormat() { @Test void create_Defaults() { List closeables = new ArrayList<>(); - OpenTelemetrySdk expectedSdk = - OpenTelemetrySdk.builder() - .setPropagators( - ContextPropagators.create( - TextMapPropagator.composite( - W3CTraceContextPropagator.getInstance(), - W3CBaggagePropagator.getInstance()))) - .build(); + OpenTelemetrySdk expectedSdk = OpenTelemetrySdk.builder().build(); cleanup.addCloseable(expectedSdk); OpenTelemetrySdk sdk = diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/PropagatorFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/PropagatorFactoryTest.java index ba9f6190e95..8eb099cffa5 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/PropagatorFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/PropagatorFactoryTest.java @@ -39,11 +39,6 @@ void create(Propagator model, ContextPropagators expectedPropagators) { private static Stream createArguments() { return Stream.of( - Arguments.of( - null, - ContextPropagators.create( - TextMapPropagator.composite( - W3CTraceContextPropagator.getInstance(), W3CBaggagePropagator.getInstance()))), Arguments.of( new Propagator() .withComposite( diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ResourceFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ResourceFactoryTest.java index f1329ffcc77..37e494ee28a 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ResourceFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ResourceFactoryTest.java @@ -16,14 +16,6 @@ class ResourceFactoryTest { - @Test - void create_Null() { - assertThat( - ResourceFactory.getInstance() - .create(null, mock(SpiHelper.class), Collections.emptyList())) - .isEqualTo(Resource.getDefault()); - } - @Test void create() { assertThat( diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SamplerFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SamplerFactoryTest.java index c5c45eb1ae6..4df997c3b2a 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SamplerFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SamplerFactoryTest.java @@ -60,10 +60,6 @@ void create( private static Stream createArguments() { return Stream.of( - Arguments.of( - null, - io.opentelemetry.sdk.trace.samplers.Sampler.parentBased( - io.opentelemetry.sdk.trace.samplers.Sampler.alwaysOn())), Arguments.of( new Sampler().withAlwaysOn(new AlwaysOn()), io.opentelemetry.sdk.trace.samplers.Sampler.alwaysOn()), diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanExporterFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanExporterFactoryTest.java index 0712e745d91..b4192410110 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanExporterFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanExporterFactoryTest.java @@ -59,12 +59,6 @@ class SpanExporterFactoryTest { private SpiHelper spiHelper = SpiHelper.create(SpanExporterFactoryTest.class.getClassLoader()); - @Test - void create_Null() { - assertThat(SpanExporterFactory.getInstance().create(null, spiHelper, new ArrayList<>())) - .isNull(); - } - @Test void create_OtlpDefaults() { spiHelper = spy(spiHelper); diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanLimitsFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanLimitsFactoryTest.java index 1fc09f61f45..c6d78c3b777 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanLimitsFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanLimitsFactoryTest.java @@ -32,7 +32,6 @@ void create( private static Stream createArguments() { return Stream.of( - Arguments.of(null, io.opentelemetry.sdk.trace.SpanLimits.getDefault()), Arguments.of( SpanLimitsAndAttributeLimits.create(null, null), io.opentelemetry.sdk.trace.SpanLimits.getDefault()), diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanProcessorFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanProcessorFactoryTest.java index eb1fb1533ce..972e0a137f9 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanProcessorFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/SpanProcessorFactoryTest.java @@ -33,19 +33,6 @@ class SpanProcessorFactoryTest { private final SpiHelper spiHelper = SpiHelper.create(SpanProcessorFactoryTest.class.getClassLoader()); - @Test - void create_Null() { - List closeables = new ArrayList<>(); - - io.opentelemetry.sdk.trace.SpanProcessor processor = - SpanProcessorFactory.getInstance().create(null, spiHelper, Collections.emptyList()); - cleanup.addCloseable(processor); - cleanup.addCloseables(closeables); - - assertThat(processor.toString()) - .isEqualTo(io.opentelemetry.sdk.trace.SpanProcessor.composite().toString()); - } - @Test void create_BatchNullExporter() { assertThatThrownBy( @@ -56,7 +43,7 @@ void create_BatchNullExporter() { spiHelper, Collections.emptyList())) .isInstanceOf(ConfigurationException.class) - .hasMessage("exporter required for batch span processor"); + .hasMessage("batch span processor exporter is required but is null"); } @Test @@ -123,7 +110,7 @@ void create_SimpleNullExporter() { spiHelper, Collections.emptyList())) .isInstanceOf(ConfigurationException.class) - .hasMessage("exporter required for simple span processor"); + .hasMessage("simple span processor exporter is required but is null"); } @Test diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TextMapPropagatorFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TextMapPropagatorFactoryTest.java index a0a0f6de49d..d2355fda46d 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TextMapPropagatorFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TextMapPropagatorFactoryTest.java @@ -41,10 +41,6 @@ void create(List model, TextMapPropagator expectedPropagator) { private static Stream createArguments() { return Stream.of( - Arguments.of( - null, - TextMapPropagator.composite( - W3CTraceContextPropagator.getInstance(), W3CBaggagePropagator.getInstance())), Arguments.of( Collections.emptyList(), TextMapPropagator.composite( diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TracerProviderFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TracerProviderFactoryTest.java index b244acef40a..b3c637e124f 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TracerProviderFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/TracerProviderFactoryTest.java @@ -54,7 +54,6 @@ void create(TracerProviderAndAttributeLimits model, SdkTracerProvider expectedPr private static Stream createArguments() { return Stream.of( - Arguments.of(null, SdkTracerProvider.builder().build()), Arguments.of( TracerProviderAndAttributeLimits.create(null, null), SdkTracerProvider.builder().build()), diff --git a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ViewFactoryTest.java b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ViewFactoryTest.java index e04d5460a2d..087e68d5790 100644 --- a/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ViewFactoryTest.java +++ b/sdk-extensions/incubator/src/test/java/io/opentelemetry/sdk/extension/incubator/fileconfig/ViewFactoryTest.java @@ -6,11 +6,9 @@ package io.opentelemetry.sdk.extension.incubator.fileconfig; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; import io.opentelemetry.sdk.autoconfigure.internal.SpiHelper; -import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException; import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Aggregation; import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.ExplicitBucketHistogram; import io.opentelemetry.sdk.extension.incubator.fileconfig.internal.model.Stream; @@ -22,16 +20,6 @@ class ViewFactoryTest { - @Test - void create_Null() { - assertThatThrownBy( - () -> - ViewFactory.getInstance() - .create(null, mock(SpiHelper.class), Collections.emptyList())) - .isInstanceOf(ConfigurationException.class) - .hasMessage("stream must not be null"); - } - @Test void create_Defaults() { View expectedView = View.builder().build();