diff --git a/data-prepper-plugins/otel-logs-source/src/main/java/org/opensearch/dataprepper/plugins/source/otellogs/OTelLogsSource.java b/data-prepper-plugins/otel-logs-source/src/main/java/org/opensearch/dataprepper/plugins/source/otellogs/OTelLogsSource.java index 5e46acc18b..737f791fb3 100644 --- a/data-prepper-plugins/otel-logs-source/src/main/java/org/opensearch/dataprepper/plugins/source/otellogs/OTelLogsSource.java +++ b/data-prepper-plugins/otel-logs-source/src/main/java/org/opensearch/dataprepper/plugins/source/otellogs/OTelLogsSource.java @@ -207,9 +207,14 @@ public void stop() { } private GrpcExceptionHandlerFunction createGrpExceptionHandler() { - RetryInfoConfig retryInfo = oTelLogsSourceConfig.getRetryInfo() != null ? oTelLogsSourceConfig.getRetryInfo() : new RetryInfoConfig(100, 2000); + Duration defaultMinDelay = Duration.ofMillis(100); + Duration defaultMaxDelay = Duration.ofMillis(2000); - return new GrpcRequestExceptionHandler(pluginMetrics, Duration.ofMillis(retryInfo.getMinDelay()), Duration.ofMillis(retryInfo.getMaxDelay())); + RetryInfoConfig retryInfo = oTelLogsSourceConfig.getRetryInfo() != null + ? oTelLogsSourceConfig.getRetryInfo() + : new RetryInfoConfig(defaultMinDelay, defaultMaxDelay); + + return new GrpcRequestExceptionHandler(pluginMetrics, retryInfo.getMinDelay(), retryInfo.getMaxDelay()); } private List getAuthenticationInterceptor() { diff --git a/data-prepper-plugins/otel-logs-source/src/main/java/org/opensearch/dataprepper/plugins/source/otellogs/RetryInfoConfig.java b/data-prepper-plugins/otel-logs-source/src/main/java/org/opensearch/dataprepper/plugins/source/otellogs/RetryInfoConfig.java index 7ab544caca..e3dbf028d4 100644 --- a/data-prepper-plugins/otel-logs-source/src/main/java/org/opensearch/dataprepper/plugins/source/otellogs/RetryInfoConfig.java +++ b/data-prepper-plugins/otel-logs-source/src/main/java/org/opensearch/dataprepper/plugins/source/otellogs/RetryInfoConfig.java @@ -1,36 +1,38 @@ package org.opensearch.dataprepper.plugins.source.otellogs; +import java.time.Duration; + import com.fasterxml.jackson.annotation.JsonProperty; public class RetryInfoConfig { @JsonProperty("min_delay") - private Integer minDelay; + private Duration minDelay; @JsonProperty("max_delay") - private Integer maxDelay; + private Duration maxDelay; // Jackson needs this constructor public RetryInfoConfig() {} - public RetryInfoConfig(int minDelay, int maxDelay) { + public RetryInfoConfig(Duration minDelay, Duration maxDelay) { this.minDelay = minDelay; this.maxDelay = maxDelay; } - public int getMinDelay() { + public Duration getMinDelay() { return minDelay; } - public void setMinDelay(Integer minDelay) { + public void setMinDelay(Duration minDelay) { this.minDelay = minDelay; } - public int getMaxDelay() { + public Duration getMaxDelay() { return maxDelay; } - public void setMaxDelay(Integer maxDelay) { + public void setMaxDelay(Duration maxDelay) { this.maxDelay = maxDelay; } } diff --git a/data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OtelLogsSourceConfigTests.java b/data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OtelLogsSourceConfigTests.java index 963035edc4..f5965b3431 100644 --- a/data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OtelLogsSourceConfigTests.java +++ b/data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OtelLogsSourceConfigTests.java @@ -13,6 +13,7 @@ import org.opensearch.dataprepper.model.configuration.PluginSetting; import org.opensearch.dataprepper.plugins.codec.CompressionOption; +import java.time.Duration; import java.util.HashMap; import java.util.Map; import java.util.stream.Stream; @@ -322,7 +323,7 @@ private PluginSetting completePluginSettingForOtelLogsSource(final int requestTi settings.put(SSL_KEY_FILE, sslKeyFile); settings.put(THREAD_COUNT, threadCount); settings.put(MAX_CONNECTION_COUNT, maxConnectionCount); - settings.put(OTelLogsSourceConfig.RETRY_INFO, new RetryInfoConfig(50, 100)); + settings.put(OTelLogsSourceConfig.RETRY_INFO, new RetryInfoConfig(Duration.ofMillis(50), Duration.ofMillis(100))); return new PluginSetting(PLUGIN_NAME, settings); } } diff --git a/data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OtelLogsSourceRetryInfoTest.java b/data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OtelLogsSourceRetryInfoTest.java index 41de6302ba..a2aab9259b 100644 --- a/data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OtelLogsSourceRetryInfoTest.java +++ b/data-prepper-plugins/otel-logs-source/src/test/java/org/opensearch/dataprepper/plugins/source/otellogs/OtelLogsSourceRetryInfoTest.java @@ -59,7 +59,7 @@ class OtelLogsSourceRetryInfoTest { private static final String GRPC_ENDPOINT = "gproto+http://127.0.0.1:21892/"; private static final String TEST_PIPELINE_NAME = "test_pipeline"; - private static final RetryInfoConfig TEST_RETRY_INFO = new RetryInfoConfig(100, 2000); + private static final RetryInfoConfig TEST_RETRY_INFO = new RetryInfoConfig(Duration.ofMillis(100), Duration.ofMillis(2000)); @Mock private PluginFactory pluginFactory;