|
30 | 30 | import java.util.Collections; |
31 | 31 | import java.util.List; |
32 | 32 | import java.util.Map; |
| 33 | +import java.util.concurrent.TimeUnit; |
33 | 34 | import java.util.concurrent.atomic.AtomicReference; |
34 | 35 | import java.util.stream.Stream; |
35 | 36 | import javax.annotation.Nullable; |
@@ -469,4 +470,57 @@ private static DefaultAggregationSelector configureHistogramDefaultAggregation( |
469 | 470 | // We apply the temporality selector to a HISTOGRAM instrument to simplify assertions |
470 | 471 | return aggregationRef.get(); |
471 | 472 | } |
| 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 | + } |
472 | 526 | } |
0 commit comments