Skip to content

Commit 84a2913

Browse files
committed
add tests for timeunits
1 parent 12abb37 commit 84a2913

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

exporters/otlp/all/src/test/java/io/opentelemetry/exporter/otlp/internal/OtlpConfigUtilTest.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.Collections;
3131
import java.util.List;
3232
import java.util.Map;
33+
import java.util.concurrent.TimeUnit;
3334
import java.util.concurrent.atomic.AtomicReference;
3435
import java.util.stream.Stream;
3536
import javax.annotation.Nullable;
@@ -469,4 +470,57 @@ private static DefaultAggregationSelector configureHistogramDefaultAggregation(
469470
// We apply the temporality selector to a HISTOGRAM instrument to simplify assertions
470471
return aggregationRef.get();
471472
}
473+
474+
@Test
475+
void configureOtlpExporterBuilder_ThrottlingLoggerTimeUnit() {
476+
// Test default value
477+
assertThat(configureThrottlingLoggerTimeUnit(Collections.emptyMap()))
478+
.isEqualTo(TimeUnit.MINUTES);
479+
assertThat(
480+
configureThrottlingLoggerTimeUnit(
481+
ImmutableMap.of("otel.exporter.otlp.logtimeunit", "invalid")))
482+
.isEqualTo(TimeUnit.MINUTES);
483+
assertThat(
484+
configureThrottlingLoggerTimeUnit(
485+
ImmutableMap.of("otel.exporter.otlp.logtimeunit", "SECONDS")))
486+
.isEqualTo(TimeUnit.SECONDS);
487+
assertThat(
488+
configureThrottlingLoggerTimeUnit(
489+
ImmutableMap.of("otel.exporter.otlp.logtimeunit", "HOURS")))
490+
.isEqualTo(TimeUnit.HOURS);
491+
assertThat(
492+
configureThrottlingLoggerTimeUnit(
493+
ImmutableMap.of("otel.exporter.otlp.logtimeunit", "DAYS")))
494+
.isEqualTo(TimeUnit.DAYS);
495+
assertThat(
496+
configureThrottlingLoggerTimeUnit(
497+
ImmutableMap.of("otel.exporter.otlp.logtimeunit", "MINUTES")))
498+
.isEqualTo(TimeUnit.MINUTES);
499+
assertThat(
500+
configureThrottlingLoggerTimeUnit(
501+
ImmutableMap.of("otel.exporter.otlp.logtimeunit", "hours")))
502+
.isEqualTo(TimeUnit.HOURS);
503+
}
504+
505+
/** Configure and return the time unit. */
506+
private static TimeUnit configureThrottlingLoggerTimeUnit(Map<String, String> properties) {
507+
AtomicReference<TimeUnit> throttlingLoggerTimeUnit = new AtomicReference<>();
508+
509+
OtlpConfigUtil.configureOtlpExporterBuilder(
510+
DATA_TYPE_LOGS,
511+
DefaultConfigProperties.createFromMap(properties),
512+
value -> {},
513+
value -> {},
514+
(value1, value2) -> {},
515+
value -> {},
516+
value -> {},
517+
value -> {},
518+
(value1, value2) -> {},
519+
value -> {},
520+
value -> {},
521+
(value1, value2) -> {},
522+
throttlingLoggerTimeUnit::set);
523+
524+
return throttlingLoggerTimeUnit.get();
525+
}
472526
}

0 commit comments

Comments
 (0)