Config properties from map (#5782)

This commit is contained in:
jack-berg 2023-08-30 09:33:39 -05:00 committed by GitHub
parent 5aa83c87fe
commit 73faa33b99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 137 additions and 148 deletions

View File

@ -29,7 +29,7 @@ class JaegerGrpcSpanExporterProviderTest {
@Test @Test
void createExporter_Default() { void createExporter_Default() {
try (SpanExporter spanExporter = try (SpanExporter spanExporter =
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap()))) { provider.createExporter(DefaultConfigProperties.createFromMap(Collections.emptyMap()))) {
assertThat(spanExporter) assertThat(spanExporter)
.isInstanceOf(io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter.class); .isInstanceOf(io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter.class);
assertThat(spanExporter) assertThat(spanExporter)
@ -52,7 +52,7 @@ class JaegerGrpcSpanExporterProviderTest {
config.put("otel.exporter.jaeger.timeout", "1s"); config.put("otel.exporter.jaeger.timeout", "1s");
try (SpanExporter spanExporter = try (SpanExporter spanExporter =
provider.createExporter(DefaultConfigProperties.createForTest(config))) { provider.createExporter(DefaultConfigProperties.createFromMap(config))) {
assertThat(spanExporter) assertThat(spanExporter)
.isInstanceOf(io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter.class); .isInstanceOf(io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter.class);
assertThat(spanExporter) assertThat(spanExporter)

View File

@ -21,7 +21,7 @@ class LoggingExporterProviderTest {
LoggingLogRecordExporterProvider provider = new LoggingLogRecordExporterProvider(); LoggingLogRecordExporterProvider provider = new LoggingLogRecordExporterProvider();
assertThat(provider.getName()).isEqualTo("logging-otlp"); assertThat(provider.getName()).isEqualTo("logging-otlp");
assertThat( assertThat(
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap()))) provider.createExporter(DefaultConfigProperties.createFromMap(Collections.emptyMap())))
.isInstanceOf(OtlpJsonLoggingLogRecordExporter.class); .isInstanceOf(OtlpJsonLoggingLogRecordExporter.class);
} }
@ -30,7 +30,7 @@ class LoggingExporterProviderTest {
LoggingMetricExporterProvider provider = new LoggingMetricExporterProvider(); LoggingMetricExporterProvider provider = new LoggingMetricExporterProvider();
assertThat(provider.getName()).isEqualTo("logging-otlp"); assertThat(provider.getName()).isEqualTo("logging-otlp");
assertThat( assertThat(
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap()))) provider.createExporter(DefaultConfigProperties.createFromMap(Collections.emptyMap())))
.isInstanceOf(OtlpJsonLoggingMetricExporter.class); .isInstanceOf(OtlpJsonLoggingMetricExporter.class);
} }
@ -39,7 +39,7 @@ class LoggingExporterProviderTest {
LoggingSpanExporterProvider provider = new LoggingSpanExporterProvider(); LoggingSpanExporterProvider provider = new LoggingSpanExporterProvider();
assertThat(provider.getName()).isEqualTo("logging-otlp"); assertThat(provider.getName()).isEqualTo("logging-otlp");
assertThat( assertThat(
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap()))) provider.createExporter(DefaultConfigProperties.createFromMap(Collections.emptyMap())))
.isInstanceOf(OtlpJsonLoggingSpanExporter.class); .isInstanceOf(OtlpJsonLoggingSpanExporter.class);
} }
} }

View File

@ -39,20 +39,20 @@ class OtlpConfigUtilTest {
void getOtlpProtocolDefault() { void getOtlpProtocolDefault() {
assertThat( assertThat(
OtlpConfigUtil.getOtlpProtocol( OtlpConfigUtil.getOtlpProtocol(
DATA_TYPE_TRACES, DefaultConfigProperties.createForTest(Collections.emptyMap()))) DATA_TYPE_TRACES, DefaultConfigProperties.createFromMap(Collections.emptyMap())))
.isEqualTo(PROTOCOL_GRPC); .isEqualTo(PROTOCOL_GRPC);
assertThat( assertThat(
OtlpConfigUtil.getOtlpProtocol( OtlpConfigUtil.getOtlpProtocol(
DATA_TYPE_TRACES, DATA_TYPE_TRACES,
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of("otel.exporter.otlp.protocol", "foo")))) ImmutableMap.of("otel.exporter.otlp.protocol", "foo"))))
.isEqualTo("foo"); .isEqualTo("foo");
assertThat( assertThat(
OtlpConfigUtil.getOtlpProtocol( OtlpConfigUtil.getOtlpProtocol(
DATA_TYPE_TRACES, DATA_TYPE_TRACES,
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of( ImmutableMap.of(
"otel.exporter.otlp.protocol", "foo", "otel.exporter.otlp.protocol", "foo",
"otel.exporter.otlp.traces.protocol", "bar")))) "otel.exporter.otlp.traces.protocol", "bar"))))
@ -318,7 +318,7 @@ class OtlpConfigUtilTest {
OtlpConfigUtil.configureOtlpExporterBuilder( OtlpConfigUtil.configureOtlpExporterBuilder(
dataType, dataType,
DefaultConfigProperties.createForTest(properties), DefaultConfigProperties.createFromMap(properties),
endpoint::set, endpoint::set,
(value1, value2) -> {}, (value1, value2) -> {},
value -> {}, value -> {},
@ -362,7 +362,7 @@ class OtlpConfigUtilTest {
Map<String, String> properties) { Map<String, String> properties) {
AtomicReference<AggregationTemporalitySelector> temporalityRef = new AtomicReference<>(); AtomicReference<AggregationTemporalitySelector> temporalityRef = new AtomicReference<>();
OtlpConfigUtil.configureOtlpAggregationTemporality( OtlpConfigUtil.configureOtlpAggregationTemporality(
DefaultConfigProperties.createForTest(properties), temporalityRef::set); DefaultConfigProperties.createFromMap(properties), temporalityRef::set);
// We apply the temporality selector to a HISTOGRAM instrument to simplify assertions // We apply the temporality selector to a HISTOGRAM instrument to simplify assertions
return temporalityRef.get().getAggregationTemporality(InstrumentType.HISTOGRAM); return temporalityRef.get().getAggregationTemporality(InstrumentType.HISTOGRAM);
} }
@ -409,7 +409,7 @@ class OtlpConfigUtilTest {
Map<String, String> properties) { Map<String, String> properties) {
AtomicReference<DefaultAggregationSelector> aggregationRef = new AtomicReference<>(); AtomicReference<DefaultAggregationSelector> aggregationRef = new AtomicReference<>();
OtlpConfigUtil.configureOtlpHistogramDefaultAggregation( OtlpConfigUtil.configureOtlpHistogramDefaultAggregation(
DefaultConfigProperties.createForTest(properties), aggregationRef::set); DefaultConfigProperties.createFromMap(properties), aggregationRef::set);
// We apply the temporality selector to a HISTOGRAM instrument to simplify assertions // We apply the temporality selector to a HISTOGRAM instrument to simplify assertions
return aggregationRef.get(); return aggregationRef.get();
} }

View File

@ -92,7 +92,7 @@ class OtlpLogRecordExporterProviderTest {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
provider.createExporter( provider.createExporter(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.exporter.otlp.protocol", "foo")))) Collections.singletonMap("otel.exporter.otlp.protocol", "foo"))))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Unsupported OTLP logs protocol: foo"); .hasMessageContaining("Unsupported OTLP logs protocol: foo");
@ -103,12 +103,12 @@ class OtlpLogRecordExporterProviderTest {
// Verifies createExporter after resetting the spy overrides // Verifies createExporter after resetting the spy overrides
Mockito.reset(provider); Mockito.reset(provider);
try (LogRecordExporter exporter = try (LogRecordExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap()))) { provider.createExporter(DefaultConfigProperties.createFromMap(Collections.emptyMap()))) {
assertThat(exporter).isInstanceOf(OtlpGrpcLogRecordExporter.class); assertThat(exporter).isInstanceOf(OtlpGrpcLogRecordExporter.class);
} }
try (LogRecordExporter exporter = try (LogRecordExporter exporter =
provider.createExporter( provider.createExporter(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.exporter.otlp.protocol", "http/protobuf")))) { Collections.singletonMap("otel.exporter.otlp.protocol", "http/protobuf")))) {
assertThat(exporter).isInstanceOf(OtlpHttpLogRecordExporter.class); assertThat(exporter).isInstanceOf(OtlpHttpLogRecordExporter.class);
} }
@ -117,7 +117,7 @@ class OtlpLogRecordExporterProviderTest {
@Test @Test
void createExporter_GrpcDefaults() { void createExporter_GrpcDefaults() {
try (LogRecordExporter exporter = try (LogRecordExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap()))) { provider.createExporter(DefaultConfigProperties.createFromMap(Collections.emptyMap()))) {
assertThat(exporter).isInstanceOf(OtlpGrpcLogRecordExporter.class); assertThat(exporter).isInstanceOf(OtlpGrpcLogRecordExporter.class);
verify(grpcBuilder, times(1)).build(); verify(grpcBuilder, times(1)).build();
verify(grpcBuilder, never()).setEndpoint(any()); verify(grpcBuilder, never()).setEndpoint(any());
@ -144,7 +144,7 @@ class OtlpLogRecordExporterProviderTest {
config.put("otel.experimental.exporter.otlp.retry.enabled", "true"); config.put("otel.experimental.exporter.otlp.retry.enabled", "true");
try (LogRecordExporter exporter = try (LogRecordExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(config))) { provider.createExporter(DefaultConfigProperties.createFromMap(config))) {
assertThat(exporter).isInstanceOf(OtlpGrpcLogRecordExporter.class); assertThat(exporter).isInstanceOf(OtlpGrpcLogRecordExporter.class);
verify(grpcBuilder, times(1)).build(); verify(grpcBuilder, times(1)).build();
verify(grpcBuilder).setEndpoint("https://localhost:443/"); verify(grpcBuilder).setEndpoint("https://localhost:443/");
@ -178,7 +178,7 @@ class OtlpLogRecordExporterProviderTest {
config.put("otel.exporter.otlp.logs.timeout", "15s"); config.put("otel.exporter.otlp.logs.timeout", "15s");
try (LogRecordExporter exporter = try (LogRecordExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(config))) { provider.createExporter(DefaultConfigProperties.createFromMap(config))) {
assertThat(exporter).isInstanceOf(OtlpGrpcLogRecordExporter.class); assertThat(exporter).isInstanceOf(OtlpGrpcLogRecordExporter.class);
verify(grpcBuilder, times(1)).build(); verify(grpcBuilder, times(1)).build();
verify(grpcBuilder).setEndpoint("https://localhost:443/"); verify(grpcBuilder).setEndpoint("https://localhost:443/");
@ -196,7 +196,7 @@ class OtlpLogRecordExporterProviderTest {
void createExporter_HttpDefaults() { void createExporter_HttpDefaults() {
try (LogRecordExporter exporter = try (LogRecordExporter exporter =
provider.createExporter( provider.createExporter(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.exporter.otlp.logs.protocol", "http/protobuf")))) { Collections.singletonMap("otel.exporter.otlp.logs.protocol", "http/protobuf")))) {
assertThat(exporter).isInstanceOf(OtlpHttpLogRecordExporter.class); assertThat(exporter).isInstanceOf(OtlpHttpLogRecordExporter.class);
verify(httpBuilder, times(1)).build(); verify(httpBuilder, times(1)).build();
@ -225,7 +225,7 @@ class OtlpLogRecordExporterProviderTest {
config.put("otel.experimental.exporter.otlp.retry.enabled", "true"); config.put("otel.experimental.exporter.otlp.retry.enabled", "true");
try (LogRecordExporter exporter = try (LogRecordExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(config))) { provider.createExporter(DefaultConfigProperties.createFromMap(config))) {
assertThat(exporter).isInstanceOf(OtlpHttpLogRecordExporter.class); assertThat(exporter).isInstanceOf(OtlpHttpLogRecordExporter.class);
verify(httpBuilder, times(1)).build(); verify(httpBuilder, times(1)).build();
verify(httpBuilder).setEndpoint("https://localhost:443/v1/logs"); verify(httpBuilder).setEndpoint("https://localhost:443/v1/logs");
@ -261,7 +261,7 @@ class OtlpLogRecordExporterProviderTest {
config.put("otel.exporter.otlp.logs.timeout", "15s"); config.put("otel.exporter.otlp.logs.timeout", "15s");
try (LogRecordExporter exporter = try (LogRecordExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(config))) { provider.createExporter(DefaultConfigProperties.createFromMap(config))) {
assertThat(exporter).isInstanceOf(OtlpHttpLogRecordExporter.class); assertThat(exporter).isInstanceOf(OtlpHttpLogRecordExporter.class);
verify(httpBuilder, times(1)).build(); verify(httpBuilder, times(1)).build();
verify(httpBuilder).setEndpoint("https://localhost:443/v1/logs"); verify(httpBuilder).setEndpoint("https://localhost:443/v1/logs");

View File

@ -92,7 +92,7 @@ class OtlpMetricExporterProviderTest {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
provider.createExporter( provider.createExporter(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.exporter.otlp.protocol", "foo")))) Collections.singletonMap("otel.exporter.otlp.protocol", "foo"))))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Unsupported OTLP metrics protocol: foo"); .hasMessageContaining("Unsupported OTLP metrics protocol: foo");
@ -103,12 +103,12 @@ class OtlpMetricExporterProviderTest {
// Verifies createExporter after resetting the spy overrides // Verifies createExporter after resetting the spy overrides
Mockito.reset(provider); Mockito.reset(provider);
try (MetricExporter exporter = try (MetricExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap()))) { provider.createExporter(DefaultConfigProperties.createFromMap(Collections.emptyMap()))) {
assertThat(exporter).isInstanceOf(OtlpGrpcMetricExporter.class); assertThat(exporter).isInstanceOf(OtlpGrpcMetricExporter.class);
} }
try (MetricExporter exporter = try (MetricExporter exporter =
provider.createExporter( provider.createExporter(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.exporter.otlp.protocol", "http/protobuf")))) { Collections.singletonMap("otel.exporter.otlp.protocol", "http/protobuf")))) {
assertThat(exporter).isInstanceOf(OtlpHttpMetricExporter.class); assertThat(exporter).isInstanceOf(OtlpHttpMetricExporter.class);
} }
@ -117,7 +117,7 @@ class OtlpMetricExporterProviderTest {
@Test @Test
void createExporter_GrpcDefaults() { void createExporter_GrpcDefaults() {
try (MetricExporter exporter = try (MetricExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap()))) { provider.createExporter(DefaultConfigProperties.createFromMap(Collections.emptyMap()))) {
assertThat(exporter).isInstanceOf(OtlpGrpcMetricExporter.class); assertThat(exporter).isInstanceOf(OtlpGrpcMetricExporter.class);
verify(grpcBuilder, times(1)).build(); verify(grpcBuilder, times(1)).build();
verify(grpcBuilder, never()).setEndpoint(any()); verify(grpcBuilder, never()).setEndpoint(any());
@ -144,7 +144,7 @@ class OtlpMetricExporterProviderTest {
config.put("otel.experimental.exporter.otlp.retry.enabled", "true"); config.put("otel.experimental.exporter.otlp.retry.enabled", "true");
try (MetricExporter exporter = try (MetricExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(config))) { provider.createExporter(DefaultConfigProperties.createFromMap(config))) {
assertThat(exporter).isInstanceOf(OtlpGrpcMetricExporter.class); assertThat(exporter).isInstanceOf(OtlpGrpcMetricExporter.class);
verify(grpcBuilder, times(1)).build(); verify(grpcBuilder, times(1)).build();
verify(grpcBuilder).setEndpoint("https://localhost:443/"); verify(grpcBuilder).setEndpoint("https://localhost:443/");
@ -178,7 +178,7 @@ class OtlpMetricExporterProviderTest {
config.put("otel.exporter.otlp.metrics.timeout", "15s"); config.put("otel.exporter.otlp.metrics.timeout", "15s");
try (MetricExporter exporter = try (MetricExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(config))) { provider.createExporter(DefaultConfigProperties.createFromMap(config))) {
assertThat(exporter).isInstanceOf(OtlpGrpcMetricExporter.class); assertThat(exporter).isInstanceOf(OtlpGrpcMetricExporter.class);
verify(grpcBuilder, times(1)).build(); verify(grpcBuilder, times(1)).build();
verify(grpcBuilder).setEndpoint("https://localhost:443/"); verify(grpcBuilder).setEndpoint("https://localhost:443/");
@ -196,7 +196,7 @@ class OtlpMetricExporterProviderTest {
void createExporter_HttpDefaults() { void createExporter_HttpDefaults() {
try (MetricExporter exporter = try (MetricExporter exporter =
provider.createExporter( provider.createExporter(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap( Collections.singletonMap(
"otel.exporter.otlp.metrics.protocol", "http/protobuf")))) { "otel.exporter.otlp.metrics.protocol", "http/protobuf")))) {
assertThat(exporter).isInstanceOf(OtlpHttpMetricExporter.class); assertThat(exporter).isInstanceOf(OtlpHttpMetricExporter.class);
@ -226,7 +226,7 @@ class OtlpMetricExporterProviderTest {
config.put("otel.experimental.exporter.otlp.retry.enabled", "true"); config.put("otel.experimental.exporter.otlp.retry.enabled", "true");
try (MetricExporter exporter = try (MetricExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(config))) { provider.createExporter(DefaultConfigProperties.createFromMap(config))) {
assertThat(exporter).isInstanceOf(OtlpHttpMetricExporter.class); assertThat(exporter).isInstanceOf(OtlpHttpMetricExporter.class);
verify(httpBuilder, times(1)).build(); verify(httpBuilder, times(1)).build();
verify(httpBuilder).setEndpoint("https://localhost:443/v1/metrics"); verify(httpBuilder).setEndpoint("https://localhost:443/v1/metrics");
@ -262,7 +262,7 @@ class OtlpMetricExporterProviderTest {
config.put("otel.exporter.otlp.metrics.timeout", "15s"); config.put("otel.exporter.otlp.metrics.timeout", "15s");
try (MetricExporter exporter = try (MetricExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(config))) { provider.createExporter(DefaultConfigProperties.createFromMap(config))) {
assertThat(exporter).isInstanceOf(OtlpHttpMetricExporter.class); assertThat(exporter).isInstanceOf(OtlpHttpMetricExporter.class);
verify(httpBuilder, times(1)).build(); verify(httpBuilder, times(1)).build();
verify(httpBuilder).setEndpoint("https://localhost:443/v1/metrics"); verify(httpBuilder).setEndpoint("https://localhost:443/v1/metrics");

View File

@ -92,7 +92,7 @@ class OtlpSpanExporterProviderTest {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
provider.createExporter( provider.createExporter(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.exporter.otlp.protocol", "foo")))) Collections.singletonMap("otel.exporter.otlp.protocol", "foo"))))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
.hasMessageContaining("Unsupported OTLP traces protocol: foo"); .hasMessageContaining("Unsupported OTLP traces protocol: foo");
@ -103,12 +103,12 @@ class OtlpSpanExporterProviderTest {
// Verifies createExporter after resetting the spy overrides // Verifies createExporter after resetting the spy overrides
Mockito.reset(provider); Mockito.reset(provider);
try (SpanExporter exporter = try (SpanExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap()))) { provider.createExporter(DefaultConfigProperties.createFromMap(Collections.emptyMap()))) {
assertThat(exporter).isInstanceOf(OtlpGrpcSpanExporter.class); assertThat(exporter).isInstanceOf(OtlpGrpcSpanExporter.class);
} }
try (SpanExporter exporter = try (SpanExporter exporter =
provider.createExporter( provider.createExporter(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.exporter.otlp.protocol", "http/protobuf")))) { Collections.singletonMap("otel.exporter.otlp.protocol", "http/protobuf")))) {
assertThat(exporter).isInstanceOf(OtlpHttpSpanExporter.class); assertThat(exporter).isInstanceOf(OtlpHttpSpanExporter.class);
} }
@ -117,7 +117,7 @@ class OtlpSpanExporterProviderTest {
@Test @Test
void createExporter_GrpcDefaults() { void createExporter_GrpcDefaults() {
try (SpanExporter exporter = try (SpanExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap()))) { provider.createExporter(DefaultConfigProperties.createFromMap(Collections.emptyMap()))) {
assertThat(exporter).isInstanceOf(OtlpGrpcSpanExporter.class); assertThat(exporter).isInstanceOf(OtlpGrpcSpanExporter.class);
verify(grpcBuilder, times(1)).build(); verify(grpcBuilder, times(1)).build();
verify(grpcBuilder, never()).setEndpoint(any()); verify(grpcBuilder, never()).setEndpoint(any());
@ -144,7 +144,7 @@ class OtlpSpanExporterProviderTest {
config.put("otel.experimental.exporter.otlp.retry.enabled", "true"); config.put("otel.experimental.exporter.otlp.retry.enabled", "true");
try (SpanExporter exporter = try (SpanExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(config))) { provider.createExporter(DefaultConfigProperties.createFromMap(config))) {
assertThat(exporter).isInstanceOf(OtlpGrpcSpanExporter.class); assertThat(exporter).isInstanceOf(OtlpGrpcSpanExporter.class);
verify(grpcBuilder, times(1)).build(); verify(grpcBuilder, times(1)).build();
verify(grpcBuilder).setEndpoint("https://localhost:443/"); verify(grpcBuilder).setEndpoint("https://localhost:443/");
@ -178,7 +178,7 @@ class OtlpSpanExporterProviderTest {
config.put("otel.exporter.otlp.traces.timeout", "15s"); config.put("otel.exporter.otlp.traces.timeout", "15s");
try (SpanExporter exporter = try (SpanExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(config))) { provider.createExporter(DefaultConfigProperties.createFromMap(config))) {
assertThat(exporter).isInstanceOf(OtlpGrpcSpanExporter.class); assertThat(exporter).isInstanceOf(OtlpGrpcSpanExporter.class);
verify(grpcBuilder, times(1)).build(); verify(grpcBuilder, times(1)).build();
verify(grpcBuilder).setEndpoint("https://localhost:443/"); verify(grpcBuilder).setEndpoint("https://localhost:443/");
@ -196,7 +196,7 @@ class OtlpSpanExporterProviderTest {
void createExporter_HttpDefaults() { void createExporter_HttpDefaults() {
try (SpanExporter exporter = try (SpanExporter exporter =
provider.createExporter( provider.createExporter(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.exporter.otlp.traces.protocol", "http/protobuf")))) { Collections.singletonMap("otel.exporter.otlp.traces.protocol", "http/protobuf")))) {
assertThat(exporter).isInstanceOf(OtlpHttpSpanExporter.class); assertThat(exporter).isInstanceOf(OtlpHttpSpanExporter.class);
verify(httpBuilder, times(1)).build(); verify(httpBuilder, times(1)).build();
@ -225,7 +225,7 @@ class OtlpSpanExporterProviderTest {
config.put("otel.experimental.exporter.otlp.retry.enabled", "true"); config.put("otel.experimental.exporter.otlp.retry.enabled", "true");
try (SpanExporter exporter = try (SpanExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(config))) { provider.createExporter(DefaultConfigProperties.createFromMap(config))) {
assertThat(exporter).isInstanceOf(OtlpHttpSpanExporter.class); assertThat(exporter).isInstanceOf(OtlpHttpSpanExporter.class);
verify(httpBuilder, times(1)).build(); verify(httpBuilder, times(1)).build();
verify(httpBuilder).setEndpoint("https://localhost:443/v1/traces"); verify(httpBuilder).setEndpoint("https://localhost:443/v1/traces");
@ -261,7 +261,7 @@ class OtlpSpanExporterProviderTest {
config.put("otel.exporter.otlp.traces.timeout", "15s"); config.put("otel.exporter.otlp.traces.timeout", "15s");
try (SpanExporter exporter = try (SpanExporter exporter =
provider.createExporter(DefaultConfigProperties.createForTest(config))) { provider.createExporter(DefaultConfigProperties.createFromMap(config))) {
assertThat(exporter).isInstanceOf(OtlpHttpSpanExporter.class); assertThat(exporter).isInstanceOf(OtlpHttpSpanExporter.class);
verify(httpBuilder, times(1)).build(); verify(httpBuilder, times(1)).build();
verify(httpBuilder).setEndpoint("https://localhost:443/v1/traces"); verify(httpBuilder).setEndpoint("https://localhost:443/v1/traces");

View File

@ -76,7 +76,7 @@ class PrometheusMetricReaderProviderTest {
when(configProperties.getString(any())).thenReturn(null); when(configProperties.getString(any())).thenReturn(null);
try (MetricReader metricReader = try (MetricReader metricReader =
provider.createMetricReader(DefaultConfigProperties.createForTest(config))) { provider.createMetricReader(DefaultConfigProperties.createFromMap(config))) {
assertThat(metricReader) assertThat(metricReader)
.extracting("server", as(InstanceOfAssertFactories.type(HttpServer.class))) .extracting("server", as(InstanceOfAssertFactories.type(HttpServer.class)))
.satisfies( .satisfies(

View File

@ -28,7 +28,7 @@ class ZipkinSpanExporterProviderTest {
@Test @Test
void createExporter_Default() { void createExporter_Default() {
try (SpanExporter spanExporter = try (SpanExporter spanExporter =
provider.createExporter(DefaultConfigProperties.createForTest(Collections.emptyMap()))) { provider.createExporter(DefaultConfigProperties.createFromMap(Collections.emptyMap()))) {
assertThat(spanExporter).isInstanceOf(ZipkinSpanExporter.class); assertThat(spanExporter).isInstanceOf(ZipkinSpanExporter.class);
assertThat(spanExporter) assertThat(spanExporter)
.extracting("sender") .extracting("sender")
@ -49,7 +49,7 @@ class ZipkinSpanExporterProviderTest {
config.put("otel.exporter.zipkin.timeout", "1s"); config.put("otel.exporter.zipkin.timeout", "1s");
try (SpanExporter spanExporter = try (SpanExporter spanExporter =
provider.createExporter(DefaultConfigProperties.createForTest(config))) { provider.createExporter(DefaultConfigProperties.createFromMap(config))) {
assertThat(spanExporter).isInstanceOf(ZipkinSpanExporter.class); assertThat(spanExporter).isInstanceOf(ZipkinSpanExporter.class);
assertThat(spanExporter) assertThat(spanExporter)
.extracting("sender") .extracting("sender")

View File

@ -53,7 +53,7 @@ public final class DefaultConfigProperties implements ConfigProperties {
* Create a {@link DefaultConfigProperties} from the {@code properties}, ignoring system * Create a {@link DefaultConfigProperties} from the {@code properties}, ignoring system
* properties and environment variables. * properties and environment variables.
*/ */
public static DefaultConfigProperties createForTest(Map<String, String> properties) { public static DefaultConfigProperties createFromMap(Map<String, String> properties) {
return new DefaultConfigProperties(properties, Collections.emptyMap(), Collections.emptyMap()); return new DefaultConfigProperties(properties, Collections.emptyMap(), Collections.emptyMap());
} }

View File

@ -26,7 +26,7 @@ class ConfigPropertiesTest {
void allValid() { void allValid() {
Map<String, String> properties = makeTestProps(); Map<String, String> properties = makeTestProps();
ConfigProperties config = DefaultConfigProperties.createForTest(properties); ConfigProperties config = DefaultConfigProperties.createFromMap(properties);
assertThat(config.getString("test.string")).isEqualTo("str"); assertThat(config.getString("test.string")).isEqualTo("str");
assertThat(config.getInt("test.int")).isEqualTo(10); assertThat(config.getInt("test.int")).isEqualTo(10);
assertThat(config.getLong("test.long")).isEqualTo(20); assertThat(config.getLong("test.long")).isEqualTo(20);
@ -41,7 +41,7 @@ class ConfigPropertiesTest {
void allValidUsingHyphens() { void allValidUsingHyphens() {
Map<String, String> properties = makeTestProps(); Map<String, String> properties = makeTestProps();
ConfigProperties config = DefaultConfigProperties.createForTest(properties); ConfigProperties config = DefaultConfigProperties.createFromMap(properties);
assertThat(config.getString("test-string")).isEqualTo("str"); assertThat(config.getString("test-string")).isEqualTo("str");
assertThat(config.getInt("test-int")).isEqualTo(10); assertThat(config.getInt("test-int")).isEqualTo(10);
assertThat(config.getLong("test-long")).isEqualTo(20); assertThat(config.getLong("test-long")).isEqualTo(20);
@ -54,7 +54,7 @@ class ConfigPropertiesTest {
@Test @Test
void allMissing() { void allMissing() {
ConfigProperties config = DefaultConfigProperties.createForTest(emptyMap()); ConfigProperties config = DefaultConfigProperties.createFromMap(emptyMap());
assertThat(config.getString("test.string")).isNull(); assertThat(config.getString("test.string")).isNull();
assertThat(config.getInt("test.int")).isNull(); assertThat(config.getInt("test.int")).isNull();
assertThat(config.getLong("test.long")).isNull(); assertThat(config.getLong("test.long")).isNull();
@ -75,7 +75,7 @@ class ConfigPropertiesTest {
properties.put("test.map", ""); properties.put("test.map", "");
properties.put("test.duration", ""); properties.put("test.duration", "");
ConfigProperties config = DefaultConfigProperties.createForTest(properties); ConfigProperties config = DefaultConfigProperties.createFromMap(properties);
assertThat(config.getString("test.string")).isEmpty(); assertThat(config.getString("test.string")).isEmpty();
assertThat(config.getInt("test.int")).isNull(); assertThat(config.getInt("test.int")).isNull();
assertThat(config.getLong("test.long")).isNull(); assertThat(config.getLong("test.long")).isNull();
@ -89,13 +89,13 @@ class ConfigPropertiesTest {
void invalidInt() { void invalidInt() {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
DefaultConfigProperties.createForTest(Collections.singletonMap("int", "bar")) DefaultConfigProperties.createFromMap(Collections.singletonMap("int", "bar"))
.getInt("int")) .getInt("int"))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
.hasMessage("Invalid value for property int=bar. Must be a integer."); .hasMessage("Invalid value for property int=bar. Must be a integer.");
assertThatThrownBy( assertThatThrownBy(
() -> () ->
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("int", "999999999999999")) Collections.singletonMap("int", "999999999999999"))
.getInt("int")) .getInt("int"))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
@ -106,13 +106,13 @@ class ConfigPropertiesTest {
void invalidLong() { void invalidLong() {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
DefaultConfigProperties.createForTest(Collections.singletonMap("long", "bar")) DefaultConfigProperties.createFromMap(Collections.singletonMap("long", "bar"))
.getLong("long")) .getLong("long"))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
.hasMessage("Invalid value for property long=bar. Must be a long."); .hasMessage("Invalid value for property long=bar. Must be a long.");
assertThatThrownBy( assertThatThrownBy(
() -> () ->
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("long", "99223372036854775807")) Collections.singletonMap("long", "99223372036854775807"))
.getLong("long")) .getLong("long"))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
@ -123,13 +123,13 @@ class ConfigPropertiesTest {
void invalidDouble() { void invalidDouble() {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
DefaultConfigProperties.createForTest(Collections.singletonMap("double", "bar")) DefaultConfigProperties.createFromMap(Collections.singletonMap("double", "bar"))
.getDouble("double")) .getDouble("double"))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
.hasMessage("Invalid value for property double=bar. Must be a double."); .hasMessage("Invalid value for property double=bar. Must be a double.");
assertThatThrownBy( assertThatThrownBy(
() -> () ->
DefaultConfigProperties.createForTest(Collections.singletonMap("double", "1.0.1")) DefaultConfigProperties.createFromMap(Collections.singletonMap("double", "1.0.1"))
.getDouble("double")) .getDouble("double"))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
.hasMessage("Invalid value for property double=1.0.1. Must be a double."); .hasMessage("Invalid value for property double=1.0.1. Must be a double.");
@ -138,7 +138,7 @@ class ConfigPropertiesTest {
@Test @Test
void uncleanList() { void uncleanList() {
assertThat( assertThat(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("list", " a ,b,c , d,, ,")) Collections.singletonMap("list", " a ,b,c , d,, ,"))
.getList("list")) .getList("list"))
.containsExactly("a", "b", "c", "d"); .containsExactly("a", "b", "c", "d");
@ -147,7 +147,7 @@ class ConfigPropertiesTest {
@Test @Test
void uncleanMap() { void uncleanMap() {
assertThat( assertThat(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("map", " a=1 ,b=2,c = 3 , d= 4,, ,")) Collections.singletonMap("map", " a=1 ,b=2,c = 3 , d= 4,, ,"))
.getMap("map")) .getMap("map"))
.containsExactly(entry("a", "1"), entry("b", "2"), entry("c", "3"), entry("d", "4")); .containsExactly(entry("a", "1"), entry("b", "2"), entry("c", "3"), entry("d", "4"));
@ -157,19 +157,19 @@ class ConfigPropertiesTest {
void invalidMap() { void invalidMap() {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
DefaultConfigProperties.createForTest(Collections.singletonMap("map", "a=1,b=")) DefaultConfigProperties.createFromMap(Collections.singletonMap("map", "a=1,b="))
.getMap("map")) .getMap("map"))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
.hasMessage("Invalid map property: map=a=1,b="); .hasMessage("Invalid map property: map=a=1,b=");
assertThatThrownBy( assertThatThrownBy(
() -> () ->
DefaultConfigProperties.createForTest(Collections.singletonMap("map", "a=1,b")) DefaultConfigProperties.createFromMap(Collections.singletonMap("map", "a=1,b"))
.getMap("map")) .getMap("map"))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
.hasMessage("Invalid map property: map=a=1,b"); .hasMessage("Invalid map property: map=a=1,b");
assertThatThrownBy( assertThatThrownBy(
() -> () ->
DefaultConfigProperties.createForTest(Collections.singletonMap("map", "a=1,=b")) DefaultConfigProperties.createFromMap(Collections.singletonMap("map", "a=1,=b"))
.getMap("map")) .getMap("map"))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
.hasMessage("Invalid map property: map=a=1,=b"); .hasMessage("Invalid map property: map=a=1,=b");
@ -179,13 +179,13 @@ class ConfigPropertiesTest {
void invalidDuration() { void invalidDuration() {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
DefaultConfigProperties.createForTest(Collections.singletonMap("duration", "1a1ms")) DefaultConfigProperties.createFromMap(Collections.singletonMap("duration", "1a1ms"))
.getDuration("duration")) .getDuration("duration"))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
.hasMessage("Invalid duration property duration=1a1ms. Expected number, found: 1a1"); .hasMessage("Invalid duration property duration=1a1ms. Expected number, found: 1a1");
assertThatThrownBy( assertThatThrownBy(
() -> () ->
DefaultConfigProperties.createForTest(Collections.singletonMap("duration", "9mm")) DefaultConfigProperties.createFromMap(Collections.singletonMap("duration", "9mm"))
.getDuration("duration")) .getDuration("duration"))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
.hasMessage("Invalid duration property duration=9mm. Invalid duration string, found: mm"); .hasMessage("Invalid duration property duration=9mm. Invalid duration string, found: mm");
@ -194,36 +194,36 @@ class ConfigPropertiesTest {
@Test @Test
void durationUnitParsing() { void durationUnitParsing() {
assertThat( assertThat(
DefaultConfigProperties.createForTest(Collections.singletonMap("duration", "1")) DefaultConfigProperties.createFromMap(Collections.singletonMap("duration", "1"))
.getDuration("duration")) .getDuration("duration"))
.isEqualTo(Duration.ofMillis(1)); .isEqualTo(Duration.ofMillis(1));
assertThat( assertThat(
DefaultConfigProperties.createForTest(Collections.singletonMap("duration", "2ms")) DefaultConfigProperties.createFromMap(Collections.singletonMap("duration", "2ms"))
.getDuration("duration")) .getDuration("duration"))
.isEqualTo(Duration.ofMillis(2)); .isEqualTo(Duration.ofMillis(2));
assertThat( assertThat(
DefaultConfigProperties.createForTest(Collections.singletonMap("duration", "3s")) DefaultConfigProperties.createFromMap(Collections.singletonMap("duration", "3s"))
.getDuration("duration")) .getDuration("duration"))
.isEqualTo(Duration.ofSeconds(3)); .isEqualTo(Duration.ofSeconds(3));
assertThat( assertThat(
DefaultConfigProperties.createForTest(Collections.singletonMap("duration", "4m")) DefaultConfigProperties.createFromMap(Collections.singletonMap("duration", "4m"))
.getDuration("duration")) .getDuration("duration"))
.isEqualTo(Duration.ofMinutes(4)); .isEqualTo(Duration.ofMinutes(4));
assertThat( assertThat(
DefaultConfigProperties.createForTest(Collections.singletonMap("duration", "5h")) DefaultConfigProperties.createFromMap(Collections.singletonMap("duration", "5h"))
.getDuration("duration")) .getDuration("duration"))
.isEqualTo(Duration.ofHours(5)); .isEqualTo(Duration.ofHours(5));
assertThat( assertThat(
DefaultConfigProperties.createForTest(Collections.singletonMap("duration", "6d")) DefaultConfigProperties.createFromMap(Collections.singletonMap("duration", "6d"))
.getDuration("duration")) .getDuration("duration"))
.isEqualTo(Duration.ofDays(6)); .isEqualTo(Duration.ofDays(6));
// Check Space handling // Check Space handling
assertThat( assertThat(
DefaultConfigProperties.createForTest(Collections.singletonMap("duration", "7 ms")) DefaultConfigProperties.createFromMap(Collections.singletonMap("duration", "7 ms"))
.getDuration("duration")) .getDuration("duration"))
.isEqualTo(Duration.ofMillis(7)); .isEqualTo(Duration.ofMillis(7));
assertThat( assertThat(
DefaultConfigProperties.createForTest(Collections.singletonMap("duration", "8 ms")) DefaultConfigProperties.createFromMap(Collections.singletonMap("duration", "8 ms"))
.getDuration("duration")) .getDuration("duration"))
.isEqualTo(Duration.ofMillis(8)); .isEqualTo(Duration.ofMillis(8));
} }

View File

@ -34,7 +34,7 @@ class LogRecordExporterConfigurationTest {
void configureExporter_KnownSpiExportersNotOnClasspath() { void configureExporter_KnownSpiExportersNotOnClasspath() {
NamedSpiManager<LogRecordExporter> spiExportersManager = NamedSpiManager<LogRecordExporter> spiExportersManager =
LogRecordExporterConfiguration.logRecordExporterSpiManager( LogRecordExporterConfiguration.logRecordExporterSpiManager(
DefaultConfigProperties.createForTest(Collections.emptyMap()), spiHelper); DefaultConfigProperties.createFromMap(Collections.emptyMap()), spiHelper);
assertThatThrownBy(() -> configureExporter("logging", spiExportersManager)) assertThatThrownBy(() -> configureExporter("logging", spiExportersManager))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
@ -64,7 +64,7 @@ class LogRecordExporterConfigurationTest {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
LogRecordExporterConfiguration.configureLogRecordExporters( LogRecordExporterConfiguration.configureLogRecordExporters(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of("otel.logs.exporter", "otlp,otlp")), ImmutableMap.of("otel.logs.exporter", "otlp,otlp")),
spiHelper, spiHelper,
(a, unused) -> a, (a, unused) -> a,
@ -82,7 +82,7 @@ class LogRecordExporterConfigurationTest {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
LogRecordExporterConfiguration.configureLogRecordExporters( LogRecordExporterConfiguration.configureLogRecordExporters(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of("otel.logs.exporter", "foo")), ImmutableMap.of("otel.logs.exporter", "foo")),
spiHelper, spiHelper,
(a, unused) -> a, (a, unused) -> a,
@ -100,7 +100,7 @@ class LogRecordExporterConfigurationTest {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
LogRecordExporterConfiguration.configureLogRecordExporters( LogRecordExporterConfiguration.configureLogRecordExporters(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of("otel.logs.exporter", "otlp,none")), ImmutableMap.of("otel.logs.exporter", "otlp,none")),
spiHelper, spiHelper,
(a, unused) -> a, (a, unused) -> a,

View File

@ -44,7 +44,7 @@ class LoggerProviderConfigurationTest {
SdkLoggerProviderBuilder builder = SdkLoggerProvider.builder(); SdkLoggerProviderBuilder builder = SdkLoggerProvider.builder();
LoggerProviderConfiguration.configureLoggerProvider( LoggerProviderConfiguration.configureLoggerProvider(
builder, builder,
DefaultConfigProperties.createForTest(properties), DefaultConfigProperties.createFromMap(properties),
SpiHelper.create(LoggerProviderConfiguration.class.getClassLoader()), SpiHelper.create(LoggerProviderConfiguration.class.getClassLoader()),
MeterProvider.noop(), MeterProvider.noop(),
(a, unused) -> a, (a, unused) -> a,
@ -73,12 +73,12 @@ class LoggerProviderConfigurationTest {
void configureLogLimits() { void configureLogLimits() {
assertThat( assertThat(
LoggerProviderConfiguration.configureLogLimits( LoggerProviderConfiguration.configureLogLimits(
DefaultConfigProperties.createForTest(Collections.emptyMap()))) DefaultConfigProperties.createFromMap(Collections.emptyMap())))
.isEqualTo(LogLimits.getDefault()); .isEqualTo(LogLimits.getDefault());
LogLimits config = LogLimits config =
LoggerProviderConfiguration.configureLogLimits( LoggerProviderConfiguration.configureLogLimits(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of( ImmutableMap.of(
"otel.attribute.value.length.limit", "100", "otel.attribute.value.length.limit", "100",
"otel.attribute.count.limit", "5"))); "otel.attribute.count.limit", "5")));

View File

@ -51,7 +51,7 @@ class MeterProviderConfigurationTest {
SdkMeterProviderBuilder builder = SdkMeterProvider.builder(); SdkMeterProviderBuilder builder = SdkMeterProvider.builder();
MeterProviderConfiguration.configureMeterProvider( MeterProviderConfiguration.configureMeterProvider(
builder, builder,
DefaultConfigProperties.createForTest(configWithDefault), DefaultConfigProperties.createFromMap(configWithDefault),
SpiHelper.create(MeterProviderConfigurationTest.class.getClassLoader()), SpiHelper.create(MeterProviderConfigurationTest.class.getClassLoader()),
(a, b) -> a, (a, b) -> a,
new ArrayList<>()); new ArrayList<>());

View File

@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
class MetricExporterConfigurationTest { class MetricExporterConfigurationTest {
private static final ConfigProperties EMPTY = private static final ConfigProperties EMPTY =
DefaultConfigProperties.createForTest(Collections.emptyMap()); DefaultConfigProperties.createFromMap(Collections.emptyMap());
private final SpiHelper spiHelper = private final SpiHelper spiHelper =
SpiHelper.create(MetricExporterConfigurationTest.class.getClassLoader()); SpiHelper.create(MetricExporterConfigurationTest.class.getClassLoader());

View File

@ -24,7 +24,7 @@ class PropagatorConfigurationTest {
void defaultPropagators() { void defaultPropagators() {
ContextPropagators contextPropagators = ContextPropagators contextPropagators =
PropagatorConfiguration.configurePropagators( PropagatorConfiguration.configurePropagators(
DefaultConfigProperties.createForTest(Collections.emptyMap()), DefaultConfigProperties.createFromMap(Collections.emptyMap()),
spiHelper, spiHelper,
(a, unused) -> a); (a, unused) -> a);
@ -36,7 +36,7 @@ class PropagatorConfigurationTest {
void configurePropagators_none() { void configurePropagators_none() {
ContextPropagators contextPropagators = ContextPropagators contextPropagators =
PropagatorConfiguration.configurePropagators( PropagatorConfiguration.configurePropagators(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.propagators", "none")), Collections.singletonMap("otel.propagators", "none")),
spiHelper, spiHelper,
(a, unused) -> a); (a, unused) -> a);
@ -49,7 +49,7 @@ class PropagatorConfigurationTest {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
PropagatorConfiguration.configurePropagators( PropagatorConfiguration.configurePropagators(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.propagators", "none,blather")), Collections.singletonMap("otel.propagators", "none,blather")),
spiHelper, spiHelper,
(a, unused) -> a)) (a, unused) -> a))
@ -62,7 +62,7 @@ class PropagatorConfigurationTest {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
PropagatorConfiguration.configurePropagators( PropagatorConfiguration.configurePropagators(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.propagators", "b3")), Collections.singletonMap("otel.propagators", "b3")),
spiHelper, spiHelper,
(a, config) -> a)) (a, config) -> a))

View File

@ -31,7 +31,7 @@ class ResourceConfigurationFuzzTest {
public void getAttributesWithRandomValues(String value1, String value2) { public void getAttributesWithRandomValues(String value1, String value2) {
Attributes attributes = Attributes attributes =
ResourceConfiguration.createEnvironmentResource( ResourceConfiguration.createEnvironmentResource(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
singletonMap( singletonMap(
ResourceConfiguration.ATTRIBUTE_PROPERTY, ResourceConfiguration.ATTRIBUTE_PROPERTY,
"key1=" + escaper.escape(value1) + ",key2=" + escaper.escape(value2)))) "key1=" + escaper.escape(value1) + ",key2=" + escaper.escape(value2))))

View File

@ -57,7 +57,7 @@ class ResourceConfigurationTest {
void createEnvironmentResource_WithResourceAttributes() { void createEnvironmentResource_WithResourceAttributes() {
Attributes attributes = Attributes attributes =
ResourceConfiguration.createEnvironmentResource( ResourceConfiguration.createEnvironmentResource(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
singletonMap( singletonMap(
ResourceConfiguration.ATTRIBUTE_PROPERTY, ResourceConfiguration.ATTRIBUTE_PROPERTY,
"service.name=myService,appName=MyApp"))) "service.name=myService,appName=MyApp")))
@ -73,7 +73,7 @@ class ResourceConfigurationTest {
void createEnvironmentResource_WithServiceName() { void createEnvironmentResource_WithServiceName() {
Attributes attributes = Attributes attributes =
ResourceConfiguration.createEnvironmentResource( ResourceConfiguration.createEnvironmentResource(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
singletonMap(ResourceConfiguration.SERVICE_NAME_PROPERTY, "myService"))) singletonMap(ResourceConfiguration.SERVICE_NAME_PROPERTY, "myService")))
.getAttributes(); .getAttributes();
@ -84,7 +84,7 @@ class ResourceConfigurationTest {
void createEnvironmentResource_ServiceNamePriority() { void createEnvironmentResource_ServiceNamePriority() {
Attributes attributes = Attributes attributes =
ResourceConfiguration.createEnvironmentResource( ResourceConfiguration.createEnvironmentResource(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of( ImmutableMap.of(
ResourceConfiguration.ATTRIBUTE_PROPERTY, ResourceConfiguration.ATTRIBUTE_PROPERTY,
"service.name=myService,appName=MyApp", "service.name=myService,appName=MyApp",
@ -102,7 +102,7 @@ class ResourceConfigurationTest {
void createEnvironmentResource_EmptyResourceAttributes() { void createEnvironmentResource_EmptyResourceAttributes() {
Attributes attributes = Attributes attributes =
ResourceConfiguration.createEnvironmentResource( ResourceConfiguration.createEnvironmentResource(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
singletonMap(ResourceConfiguration.ATTRIBUTE_PROPERTY, ""))) singletonMap(ResourceConfiguration.ATTRIBUTE_PROPERTY, "")))
.getAttributes(); .getAttributes();
@ -112,7 +112,7 @@ class ResourceConfigurationTest {
@Test @Test
void filterAttributes() { void filterAttributes() {
ConfigProperties configProperties = ConfigProperties configProperties =
DefaultConfigProperties.createForTest(ImmutableMap.of(DISABLED_ATTRIBUTE_KEYS, "foo,bar")); DefaultConfigProperties.createFromMap(ImmutableMap.of(DISABLED_ATTRIBUTE_KEYS, "foo,bar"));
Resource resourceNoSchema = Resource resourceNoSchema =
Resource.builder().put("foo", "val").put("bar", "val").put("baz", "val").build(); Resource.builder().put("foo", "val").put("bar", "val").put("baz", "val").build();

View File

@ -22,7 +22,7 @@ class SpanExporterConfigurationTest {
void configureExporter_KnownSpiExportersNotOnClasspath() { void configureExporter_KnownSpiExportersNotOnClasspath() {
NamedSpiManager<SpanExporter> spiExportersManager = NamedSpiManager<SpanExporter> spiExportersManager =
SpanExporterConfiguration.spanExporterSpiManager( SpanExporterConfiguration.spanExporterSpiManager(
DefaultConfigProperties.createForTest(Collections.emptyMap()), DefaultConfigProperties.createFromMap(Collections.emptyMap()),
SpiHelper.create(SpanExporterConfigurationTest.class.getClassLoader())); SpiHelper.create(SpanExporterConfigurationTest.class.getClassLoader()));
assertThatThrownBy(() -> configureExporter("jaeger", spiExportersManager)) assertThatThrownBy(() -> configureExporter("jaeger", spiExportersManager))

View File

@ -47,7 +47,7 @@ import org.mockito.quality.Strictness;
class TracerProviderConfigurationTest { class TracerProviderConfigurationTest {
private static final ConfigProperties EMPTY = private static final ConfigProperties EMPTY =
DefaultConfigProperties.createForTest(Collections.emptyMap()); DefaultConfigProperties.createFromMap(Collections.emptyMap());
@RegisterExtension CleanupExtension cleanup = new CleanupExtension(); @RegisterExtension CleanupExtension cleanup = new CleanupExtension();
@ -74,7 +74,7 @@ class TracerProviderConfigurationTest {
SdkTracerProviderBuilder tracerProviderBuilder = SdkTracerProvider.builder(); SdkTracerProviderBuilder tracerProviderBuilder = SdkTracerProvider.builder();
TracerProviderConfiguration.configureTracerProvider( TracerProviderConfiguration.configureTracerProvider(
tracerProviderBuilder, tracerProviderBuilder,
DefaultConfigProperties.createForTest(properties), DefaultConfigProperties.createFromMap(properties),
spiHelper, spiHelper,
MeterProvider.noop(), MeterProvider.noop(),
(a, unused) -> a, (a, unused) -> a,
@ -130,7 +130,7 @@ class TracerProviderConfigurationTest {
try (BatchSpanProcessor processor = try (BatchSpanProcessor processor =
TracerProviderConfiguration.configureBatchSpanProcessor( TracerProviderConfiguration.configureBatchSpanProcessor(
DefaultConfigProperties.createForTest(properties), DefaultConfigProperties.createFromMap(properties),
mockSpanExporter, mockSpanExporter,
MeterProvider.noop())) { MeterProvider.noop())) {
assertThat(processor) assertThat(processor)
@ -160,7 +160,7 @@ class TracerProviderConfigurationTest {
SpanLimits config = SpanLimits config =
TracerProviderConfiguration.configureSpanLimits( TracerProviderConfiguration.configureSpanLimits(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of( ImmutableMap.of(
"otel.attribute.value.length.limit", "100", "otel.attribute.value.length.limit", "100",
"otel.attribute.count.limit", "5"))); "otel.attribute.count.limit", "5")));
@ -175,7 +175,7 @@ class TracerProviderConfigurationTest {
config = config =
TracerProviderConfiguration.configureSpanLimits( TracerProviderConfiguration.configureSpanLimits(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of( ImmutableMap.of(
"otel.attribute.value.length.limit", "100", "otel.attribute.value.length.limit", "100",
"otel.span.attribute.value.length.limit", "200", "otel.span.attribute.value.length.limit", "200",
@ -200,7 +200,7 @@ class TracerProviderConfigurationTest {
assertThat( assertThat(
TracerProviderConfiguration.configureSampler( TracerProviderConfiguration.configureSampler(
"traceidratio", "traceidratio",
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.traces.sampler.arg", "0.5")), Collections.singletonMap("otel.traces.sampler.arg", "0.5")),
spiHelper)) spiHelper))
.isEqualTo(Sampler.traceIdRatioBased(0.5)); .isEqualTo(Sampler.traceIdRatioBased(0.5));
@ -216,7 +216,7 @@ class TracerProviderConfigurationTest {
assertThat( assertThat(
TracerProviderConfiguration.configureSampler( TracerProviderConfiguration.configureSampler(
"parentbased_traceidratio", "parentbased_traceidratio",
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.traces.sampler.arg", "0.4")), Collections.singletonMap("otel.traces.sampler.arg", "0.4")),
spiHelper)) spiHelper))
.isEqualTo(Sampler.parentBased(Sampler.traceIdRatioBased(0.4))); .isEqualTo(Sampler.parentBased(Sampler.traceIdRatioBased(0.4)));

View File

@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
public class SpiHelperTest { public class SpiHelperTest {
private static final ConfigProperties EMPTY = private static final ConfigProperties EMPTY =
DefaultConfigProperties.createForTest(Collections.emptyMap()); DefaultConfigProperties.createFromMap(Collections.emptyMap());
@Test @Test
public void canRetrieveByName() { public void canRetrieveByName() {

View File

@ -33,7 +33,7 @@ class ConfigurableLogRecordExporterTest {
@Test @Test
void configureLogRecordExporters_spiExporter() { void configureLogRecordExporters_spiExporter() {
ConfigProperties config = ConfigProperties config =
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of("test.option", "true", "otel.logs.exporter", "testExporter")); ImmutableMap.of("test.option", "true", "otel.logs.exporter", "testExporter"));
List<Closeable> closeables = new ArrayList<>(); List<Closeable> closeables = new ArrayList<>();
@ -60,7 +60,7 @@ class ConfigurableLogRecordExporterTest {
@Test @Test
void configureLogRecordExporters_emptyClassLoader() { void configureLogRecordExporters_emptyClassLoader() {
ConfigProperties config = ConfigProperties config =
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of("test.option", "true", "otel.logs.exporter", "testExporter")); ImmutableMap.of("test.option", "true", "otel.logs.exporter", "testExporter"));
List<Closeable> closeables = new ArrayList<>(); List<Closeable> closeables = new ArrayList<>();

View File

@ -39,7 +39,7 @@ class ConfigurableMetricExporterTest {
@Test @Test
void configureExporter_spiExporter() { void configureExporter_spiExporter() {
ConfigProperties config = ConfigProperties config =
DefaultConfigProperties.createForTest(ImmutableMap.of("test.option", "true")); DefaultConfigProperties.createFromMap(ImmutableMap.of("test.option", "true"));
try (MetricExporter metricExporter = try (MetricExporter metricExporter =
MetricExporterConfiguration.configureExporter( MetricExporterConfiguration.configureExporter(
@ -58,7 +58,7 @@ class ConfigurableMetricExporterTest {
MetricExporterConfiguration.configureExporter( MetricExporterConfiguration.configureExporter(
"testExporter", "testExporter",
MetricExporterConfiguration.metricExporterSpiManager( MetricExporterConfiguration.metricExporterSpiManager(
DefaultConfigProperties.createForTest(Collections.emptyMap()), DefaultConfigProperties.createFromMap(Collections.emptyMap()),
SpiHelper.create(new URLClassLoader(new URL[] {}, null))))) SpiHelper.create(new URLClassLoader(new URL[] {}, null)))))
.isNull(); .isNull();
} }
@ -69,14 +69,14 @@ class ConfigurableMetricExporterTest {
MetricExporterConfiguration.configureExporter( MetricExporterConfiguration.configureExporter(
"catExporter", "catExporter",
MetricExporterConfiguration.metricExporterSpiManager( MetricExporterConfiguration.metricExporterSpiManager(
DefaultConfigProperties.createForTest(Collections.emptyMap()), spiHelper))) DefaultConfigProperties.createFromMap(Collections.emptyMap()), spiHelper)))
.isNull(); .isNull();
} }
@Test @Test
void configureMetricReaders_multipleWithNone() { void configureMetricReaders_multipleWithNone() {
ConfigProperties config = ConfigProperties config =
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of("otel.metrics.exporter", "otlp,none")); ImmutableMap.of("otel.metrics.exporter", "otlp,none"));
List<Closeable> closeables = new ArrayList<>(); List<Closeable> closeables = new ArrayList<>();
@ -92,7 +92,7 @@ class ConfigurableMetricExporterTest {
@Test @Test
void configureMetricReaders_defaultExporter() { void configureMetricReaders_defaultExporter() {
ConfigProperties config = DefaultConfigProperties.createForTest(Collections.emptyMap()); ConfigProperties config = DefaultConfigProperties.createFromMap(Collections.emptyMap());
List<Closeable> closeables = new ArrayList<>(); List<Closeable> closeables = new ArrayList<>();
List<MetricReader> metricReaders = List<MetricReader> metricReaders =
@ -114,7 +114,7 @@ class ConfigurableMetricExporterTest {
@Test @Test
void configureMetricReaders_multipleExporters() { void configureMetricReaders_multipleExporters() {
ConfigProperties config = ConfigProperties config =
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of("otel.metrics.exporter", "otlp,logging")); ImmutableMap.of("otel.metrics.exporter", "otlp,logging"));
List<Closeable> closeables = new ArrayList<>(); List<Closeable> closeables = new ArrayList<>();

View File

@ -45,7 +45,7 @@ class ConfigurableSpanExporterTest {
@Test @Test
void configureSpanExporters_spiExporter() { void configureSpanExporters_spiExporter() {
ConfigProperties config = ConfigProperties config =
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of("test.option", "true", "otel.traces.exporter", "testExporter")); ImmutableMap.of("test.option", "true", "otel.traces.exporter", "testExporter"));
List<Closeable> closeables = new ArrayList<>(); List<Closeable> closeables = new ArrayList<>();
@ -68,7 +68,7 @@ class ConfigurableSpanExporterTest {
@Test @Test
void configureSpanExporters_emptyClassLoader() { void configureSpanExporters_emptyClassLoader() {
ConfigProperties config = ConfigProperties config =
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of("test.option", "true", "otel.traces.exporter", "testExporter")); ImmutableMap.of("test.option", "true", "otel.traces.exporter", "testExporter"));
List<Closeable> closeables = new ArrayList<>(); List<Closeable> closeables = new ArrayList<>();
@ -88,7 +88,7 @@ class ConfigurableSpanExporterTest {
@Test @Test
void configureSpanExporters_duplicates() { void configureSpanExporters_duplicates() {
ConfigProperties config = ConfigProperties config =
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of("otel.traces.exporter", "otlp,otlp,logging")); ImmutableMap.of("otel.traces.exporter", "otlp,otlp,logging"));
List<Closeable> closeables = new ArrayList<>(); List<Closeable> closeables = new ArrayList<>();
@ -105,7 +105,7 @@ class ConfigurableSpanExporterTest {
@Test @Test
void configureSpanExporters_multipleWithNone() { void configureSpanExporters_multipleWithNone() {
ConfigProperties config = ConfigProperties config =
DefaultConfigProperties.createForTest(ImmutableMap.of("otel.traces.exporter", "otlp,none")); DefaultConfigProperties.createFromMap(ImmutableMap.of("otel.traces.exporter", "otlp,none"));
List<Closeable> closeables = new ArrayList<>(); List<Closeable> closeables = new ArrayList<>();
assertThatThrownBy( assertThatThrownBy(
@ -135,7 +135,7 @@ class ConfigurableSpanExporterTest {
List<SpanProcessor> spanProcessors = List<SpanProcessor> spanProcessors =
TracerProviderConfiguration.configureSpanProcessors( TracerProviderConfiguration.configureSpanProcessors(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.traces.exporter", exporterName)), Collections.singletonMap("otel.traces.exporter", exporterName)),
ImmutableMap.of(exporterName, LoggingSpanExporter.create()), ImmutableMap.of(exporterName, LoggingSpanExporter.create()),
MeterProvider.noop(), MeterProvider.noop(),
@ -153,7 +153,7 @@ class ConfigurableSpanExporterTest {
List<SpanProcessor> spanProcessors = List<SpanProcessor> spanProcessors =
TracerProviderConfiguration.configureSpanProcessors( TracerProviderConfiguration.configureSpanProcessors(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.traces.exporter", exporterName)), Collections.singletonMap("otel.traces.exporter", exporterName)),
ImmutableMap.of(exporterName, ZipkinSpanExporter.builder().build()), ImmutableMap.of(exporterName, ZipkinSpanExporter.builder().build()),
MeterProvider.noop(), MeterProvider.noop(),
@ -170,7 +170,7 @@ class ConfigurableSpanExporterTest {
List<SpanProcessor> spanProcessors = List<SpanProcessor> spanProcessors =
TracerProviderConfiguration.configureSpanProcessors( TracerProviderConfiguration.configureSpanProcessors(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.traces.exporter", "otlp,zipkin")), Collections.singletonMap("otel.traces.exporter", "otlp,zipkin")),
ImmutableMap.of( ImmutableMap.of(
"otlp", "otlp",
@ -212,7 +212,7 @@ class ConfigurableSpanExporterTest {
List<SpanProcessor> spanProcessors = List<SpanProcessor> spanProcessors =
TracerProviderConfiguration.configureSpanProcessors( TracerProviderConfiguration.configureSpanProcessors(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.traces.exporter", "logging,zipkin")), Collections.singletonMap("otel.traces.exporter", "logging,zipkin")),
ImmutableMap.of( ImmutableMap.of(
"logging", "logging",

View File

@ -29,7 +29,7 @@ class LogRecordExporterConfigurationTest {
void configureExporter_KnownSpiExportersOnClasspath() { void configureExporter_KnownSpiExportersOnClasspath() {
NamedSpiManager<LogRecordExporter> spiExportersManager = NamedSpiManager<LogRecordExporter> spiExportersManager =
LogRecordExporterConfiguration.logRecordExporterSpiManager( LogRecordExporterConfiguration.logRecordExporterSpiManager(
DefaultConfigProperties.createForTest(Collections.emptyMap()), spiHelper); DefaultConfigProperties.createFromMap(Collections.emptyMap()), spiHelper);
assertThat(LogRecordExporterConfiguration.configureExporter("logging", spiExportersManager)) assertThat(LogRecordExporterConfiguration.configureExporter("logging", spiExportersManager))
.isInstanceOf(SystemOutLogRecordExporter.class); .isInstanceOf(SystemOutLogRecordExporter.class);
@ -47,7 +47,7 @@ class LogRecordExporterConfigurationTest {
LogRecordExporterConfiguration.configureExporter( LogRecordExporterConfiguration.configureExporter(
"otlp", "otlp",
LogRecordExporterConfiguration.logRecordExporterSpiManager( LogRecordExporterConfiguration.logRecordExporterSpiManager(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of("otel.exporter.otlp.protocol", "foo")), ImmutableMap.of("otel.exporter.otlp.protocol", "foo")),
spiHelper))) spiHelper)))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)

View File

@ -43,7 +43,7 @@ class LoggerProviderConfigurationTest {
SdkLoggerProviderBuilder builder = SdkLoggerProvider.builder(); SdkLoggerProviderBuilder builder = SdkLoggerProvider.builder();
LoggerProviderConfiguration.configureLoggerProvider( LoggerProviderConfiguration.configureLoggerProvider(
builder, builder,
DefaultConfigProperties.createForTest(Collections.emptyMap()), DefaultConfigProperties.createFromMap(Collections.emptyMap()),
SpiHelper.create(LoggerProviderConfiguration.class.getClassLoader()), SpiHelper.create(LoggerProviderConfiguration.class.getClassLoader()),
MeterProvider.noop(), MeterProvider.noop(),
(a, unused) -> a, (a, unused) -> a,
@ -86,7 +86,7 @@ class LoggerProviderConfigurationTest {
List<LogRecordProcessor> logRecordProcessors = List<LogRecordProcessor> logRecordProcessors =
LoggerProviderConfiguration.configureLogRecordProcessors( LoggerProviderConfiguration.configureLogRecordProcessors(
DefaultConfigProperties.createForTest(Collections.emptyMap()), DefaultConfigProperties.createFromMap(Collections.emptyMap()),
ImmutableMap.of( ImmutableMap.of(
"logging", "logging",
SystemOutLogRecordExporter.create(), SystemOutLogRecordExporter.create(),
@ -116,7 +116,7 @@ class LoggerProviderConfigurationTest {
try (BatchLogRecordProcessor processor = try (BatchLogRecordProcessor processor =
LoggerProviderConfiguration.configureBatchLogRecordProcessor( LoggerProviderConfiguration.configureBatchLogRecordProcessor(
DefaultConfigProperties.createForTest(properties), DefaultConfigProperties.createFromMap(properties),
SystemOutLogRecordExporter.create(), SystemOutLogRecordExporter.create(),
MeterProvider.noop())) { MeterProvider.noop())) {
assertThat(processor) assertThat(processor)

View File

@ -42,7 +42,7 @@ class MeterProviderConfigurationTest {
() -> { () -> {
MeterProviderConfiguration.configureMeterProvider( MeterProviderConfiguration.configureMeterProvider(
SdkMeterProvider.builder(), SdkMeterProvider.builder(),
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of( ImmutableMap.of(
"otel.metrics.exporter", "otel.metrics.exporter",
"logging", "logging",
@ -65,7 +65,7 @@ class MeterProviderConfigurationTest {
SdkMeterProviderBuilder builder = SdkMeterProvider.builder(); SdkMeterProviderBuilder builder = SdkMeterProvider.builder();
MeterProviderConfiguration.configureMeterProvider( MeterProviderConfiguration.configureMeterProvider(
builder, builder,
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.metrics.exporter", "logging")), Collections.singletonMap("otel.metrics.exporter", "logging")),
spiHelper, spiHelper,
(a, b) -> a, (a, b) -> a,
@ -77,7 +77,7 @@ class MeterProviderConfigurationTest {
builder = SdkMeterProvider.builder(); builder = SdkMeterProvider.builder();
MeterProviderConfiguration.configureMeterProvider( MeterProviderConfiguration.configureMeterProvider(
builder, builder,
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of( ImmutableMap.of(
"otel.metrics.exporter", "otel.metrics.exporter",
"logging", "logging",

View File

@ -35,7 +35,7 @@ import org.junit.jupiter.params.provider.MethodSource;
class MetricExporterConfigurationTest { class MetricExporterConfigurationTest {
private static final ConfigProperties EMPTY = private static final ConfigProperties EMPTY =
DefaultConfigProperties.createForTest(Collections.emptyMap()); DefaultConfigProperties.createFromMap(Collections.emptyMap());
@RegisterExtension CleanupExtension cleanup = new CleanupExtension(); @RegisterExtension CleanupExtension cleanup = new CleanupExtension();
@ -101,7 +101,7 @@ class MetricExporterConfigurationTest {
MetricExporterConfiguration.configureExporter( MetricExporterConfiguration.configureExporter(
"otlp", "otlp",
MetricExporterConfiguration.metricExporterSpiManager( MetricExporterConfiguration.metricExporterSpiManager(
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of("otel.exporter.otlp.protocol", "foo")), ImmutableMap.of("otel.exporter.otlp.protocol", "foo")),
spiHelper))) spiHelper)))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)

View File

@ -32,7 +32,7 @@ class SpanExporterConfigurationTest {
void configureExporter_KnownSpiExportersOnClasspath() { void configureExporter_KnownSpiExportersOnClasspath() {
NamedSpiManager<SpanExporter> spiExportersManager = NamedSpiManager<SpanExporter> spiExportersManager =
SpanExporterConfiguration.spanExporterSpiManager( SpanExporterConfiguration.spanExporterSpiManager(
DefaultConfigProperties.createForTest(Collections.emptyMap()), spiHelper); DefaultConfigProperties.createFromMap(Collections.emptyMap()), spiHelper);
assertThat(SpanExporterConfiguration.configureExporter("jaeger", spiExportersManager)) assertThat(SpanExporterConfiguration.configureExporter("jaeger", spiExportersManager))
.isInstanceOf(io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter.class); .isInstanceOf(io.opentelemetry.exporter.jaeger.JaegerGrpcSpanExporter.class);
@ -49,7 +49,7 @@ class SpanExporterConfigurationTest {
@Test @Test
void configureOtlpSpansUnsupportedProtocol() { void configureOtlpSpansUnsupportedProtocol() {
ConfigProperties config = ConfigProperties config =
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
ImmutableMap.of("otel.exporter.otlp.protocol", "foo")); ImmutableMap.of("otel.exporter.otlp.protocol", "foo"));
assertThatThrownBy( assertThatThrownBy(
() -> () ->
@ -63,7 +63,7 @@ class SpanExporterConfigurationTest {
@Test @Test
void configureOtlpTimeout() { void configureOtlpTimeout() {
ConfigProperties config = ConfigProperties config =
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.exporter.otlp.timeout", "10")); Collections.singletonMap("otel.exporter.otlp.timeout", "10"));
try (SpanExporter exporter = try (SpanExporter exporter =
SpanExporterConfiguration.configureExporter( SpanExporterConfiguration.configureExporter(

View File

@ -29,7 +29,7 @@ public class TracerProviderConfigurationTest {
@Test @Test
void configuration() { void configuration() {
ConfigProperties config = ConfigProperties config =
DefaultConfigProperties.createForTest(ImmutableMap.of("test.option", "true")); DefaultConfigProperties.createFromMap(ImmutableMap.of("test.option", "true"));
Sampler sampler = Sampler sampler =
TracerProviderConfiguration.configureSampler("testSampler", config, spiHelper); TracerProviderConfiguration.configureSampler("testSampler", config, spiHelper);
@ -42,7 +42,7 @@ public class TracerProviderConfigurationTest {
@Test @Test
void emptyClassLoader() { void emptyClassLoader() {
ConfigProperties config = ConfigProperties config =
DefaultConfigProperties.createForTest(ImmutableMap.of("test.option", "true")); DefaultConfigProperties.createFromMap(ImmutableMap.of("test.option", "true"));
assertThatThrownBy( assertThatThrownBy(
() -> () ->
TracerProviderConfiguration.configureSampler( TracerProviderConfiguration.configureSampler(
@ -57,7 +57,7 @@ public class TracerProviderConfigurationTest {
() -> () ->
TracerProviderConfiguration.configureSampler( TracerProviderConfiguration.configureSampler(
"catSampler", "catSampler",
DefaultConfigProperties.createForTest(Collections.emptyMap()), DefaultConfigProperties.createFromMap(Collections.emptyMap()),
spiHelper)) spiHelper))
.isInstanceOf(ConfigurationException.class) .isInstanceOf(ConfigurationException.class)
.hasMessageContaining("catSampler"); .hasMessageContaining("catSampler");
@ -68,7 +68,7 @@ public class TracerProviderConfigurationTest {
assertThat( assertThat(
TracerProviderConfiguration.configureSampler( TracerProviderConfiguration.configureSampler(
"parentbased_jaeger_remote", "parentbased_jaeger_remote",
DefaultConfigProperties.createForTest(Collections.emptyMap()), DefaultConfigProperties.createFromMap(Collections.emptyMap()),
spiHelper)) spiHelper))
.satisfies( .satisfies(
sampler -> { sampler -> {

View File

@ -97,9 +97,7 @@ final class LogRecordExporterFactory
properties.put("otel.exporter.otlp.logs.client.certificate", otlp.getClientCertificate()); properties.put("otel.exporter.otlp.logs.client.certificate", otlp.getClientCertificate());
} }
// TODO(jack-berg): add method for creating from map ConfigProperties configProperties = DefaultConfigProperties.createFromMap(properties);
ConfigProperties configProperties = DefaultConfigProperties.createForTest(properties);
return FileConfigUtil.assertNotNull( return FileConfigUtil.assertNotNull(
logRecordExporterSpiManager(configProperties, spiHelper).getByName("otlp"), logRecordExporterSpiManager(configProperties, spiHelper).getByName("otlp"),
"otlp exporter"); "otlp exporter");

View File

@ -117,8 +117,7 @@ final class MetricExporterFactory
"otel.exporter.otlp.metrics.temporality.preference", model.getTemporalityPreference()); "otel.exporter.otlp.metrics.temporality.preference", model.getTemporalityPreference());
} }
// TODO(jack-berg): add method for creating from map ConfigProperties configProperties = DefaultConfigProperties.createFromMap(properties);
ConfigProperties configProperties = DefaultConfigProperties.createForTest(properties);
return FileConfigUtil.assertNotNull( return FileConfigUtil.assertNotNull(
metricExporterSpiManager(configProperties, spiHelper).getByName("otlp"), "otlp exporter"); metricExporterSpiManager(configProperties, spiHelper).getByName("otlp"), "otlp exporter");
} }
@ -126,7 +125,7 @@ final class MetricExporterFactory
private static MetricExporter createConsoleExporter(SpiHelper spiHelper) { private static MetricExporter createConsoleExporter(SpiHelper spiHelper) {
return FileConfigUtil.assertNotNull( return FileConfigUtil.assertNotNull(
metricExporterSpiManager( metricExporterSpiManager(
DefaultConfigProperties.createForTest(Collections.emptyMap()), spiHelper) DefaultConfigProperties.createFromMap(Collections.emptyMap()), spiHelper)
.getByName("logging"), .getByName("logging"),
"logging exporter"); "logging exporter");
} }

View File

@ -90,9 +90,7 @@ final class MetricReaderFactory
"otel.exporter.prometheus.port", String.valueOf(prometheusModel.getPort())); "otel.exporter.prometheus.port", String.valueOf(prometheusModel.getPort()));
} }
// TODO(jack-berg): add method for creating from map ConfigProperties configProperties = DefaultConfigProperties.createFromMap(properties);
ConfigProperties configProperties = DefaultConfigProperties.createForTest(properties);
return FileConfigUtil.addAndReturn( return FileConfigUtil.addAndReturn(
closeables, closeables,
FileConfigUtil.assertNotNull( FileConfigUtil.assertNotNull(

View File

@ -52,7 +52,7 @@ final class PropagatorsFactory implements Factory<List<String>, ContextPropagato
ConfigurablePropagatorProvider.class, ConfigurablePropagatorProvider.class,
ConfigurablePropagatorProvider::getName, ConfigurablePropagatorProvider::getName,
ConfigurablePropagatorProvider::getPropagator, ConfigurablePropagatorProvider::getPropagator,
DefaultConfigProperties.createForTest(Collections.emptyMap())); DefaultConfigProperties.createFromMap(Collections.emptyMap()));
Set<TextMapPropagator> propagators = new LinkedHashSet<>(); Set<TextMapPropagator> propagators = new LinkedHashSet<>();
for (String propagator : model) { for (String propagator : model) {
propagators.add(getPropagator(propagator, spiPropagatorsManager)); propagators.add(getPropagator(propagator, spiPropagatorsManager));

View File

@ -106,11 +106,9 @@ final class SamplerFactory
.map(entry -> entry.getKey() + "=" + entry.getValue()) .map(entry -> entry.getKey() + "=" + entry.getValue())
.collect(joining(",")); .collect(joining(","));
// TODO(jack-berg): add method for creating from map
ConfigProperties configProperties = ConfigProperties configProperties =
DefaultConfigProperties.createForTest( DefaultConfigProperties.createFromMap(
Collections.singletonMap("otel.traces.sampler.arg", otelTraceSamplerArg)); Collections.singletonMap("otel.traces.sampler.arg", otelTraceSamplerArg));
return FileConfigUtil.addAndReturn( return FileConfigUtil.addAndReturn(
closeables, closeables,
FileConfigUtil.assertNotNull( FileConfigUtil.assertNotNull(

View File

@ -107,9 +107,7 @@ final class SpanExporterFactory
properties.put("otel.exporter.otlp.traces.client.certificate", model.getClientCertificate()); properties.put("otel.exporter.otlp.traces.client.certificate", model.getClientCertificate());
} }
// TODO(jack-berg): add method for creating from map ConfigProperties configProperties = DefaultConfigProperties.createFromMap(properties);
ConfigProperties configProperties = DefaultConfigProperties.createForTest(properties);
return FileConfigUtil.assertNotNull( return FileConfigUtil.assertNotNull(
spanExporterSpiManager(configProperties, spiHelper).getByName("otlp"), "otlp exporter"); spanExporterSpiManager(configProperties, spiHelper).getByName("otlp"), "otlp exporter");
} }
@ -117,7 +115,7 @@ final class SpanExporterFactory
private static SpanExporter createConsoleExporter(SpiHelper spiHelper) { private static SpanExporter createConsoleExporter(SpiHelper spiHelper) {
return FileConfigUtil.assertNotNull( return FileConfigUtil.assertNotNull(
spanExporterSpiManager( spanExporterSpiManager(
DefaultConfigProperties.createForTest(Collections.emptyMap()), spiHelper) DefaultConfigProperties.createFromMap(Collections.emptyMap()), spiHelper)
.getByName("logging"), .getByName("logging"),
"logging exporter"); "logging exporter");
} }
@ -134,9 +132,7 @@ final class SpanExporterFactory
properties.put("otel.exporter.zipkin.timeout", Integer.toString(model.getTimeout())); properties.put("otel.exporter.zipkin.timeout", Integer.toString(model.getTimeout()));
} }
// TODO(jack-berg): add method for creating from map ConfigProperties configProperties = DefaultConfigProperties.createFromMap(properties);
ConfigProperties configProperties = DefaultConfigProperties.createForTest(properties);
return FileConfigUtil.assertNotNull( return FileConfigUtil.assertNotNull(
spanExporterSpiManager(configProperties, spiHelper).getByName("zipkin"), "zipkin exporter"); spanExporterSpiManager(configProperties, spiHelper).getByName("zipkin"), "zipkin exporter");
} }