Skip to content

Commit

Permalink
Merge pull request #285 from nico-duv/TimeOut
Browse files Browse the repository at this point in the history
feat(TimeOut): Enable the TimeOut Settings from HttpEventCollectorSender #284
  • Loading branch information
vietk authored Sep 18, 2024
2 parents 385736a + 39156e3 commit 2d2cdd3
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 3 deletions.
92 changes: 90 additions & 2 deletions docs/modules/ROOT/pages/includes/quarkus-log-handler-splunk.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,95 @@ endif::add-copy-button-to-env-var[]
`block`, `discard`
|`block`
a| [[quarkus-log-handler-splunk_quarkus-log-handler-splunk-connectTimeout]]`link:#quarkus-log-handler-splunk_quarkus-log-handler-splunk-connectTimeout[quarkus.log.handler.splunk.connectTimeout]`
[.description]
--
Sets the default connect timeout for new connections in milliseconds.
ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LOG_HANDLER_SPLUNK_CONNECTTIMEOUT+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LOG_HANDLER_SPLUNK_CONNECTTIMEOUT+++`
endif::add-copy-button-to-env-var[]
-- a|
long
|`3000`
a| [[quarkus-log-handler-splunk_quarkus-log-handler-splunk-callTimeout]]`link:#quarkus-log-handler-splunk_quarkus-log-handler-splunk-callTimeout[quarkus.log.handler.splunk.callTimeout]`
[.description]
--
Sets the default timeout for complete calls in milliseconds.
ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LOG_HANDLER_SPLUNK_CALLTIMEOUT+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LOG_HANDLER_SPLUNK_CALLTIMEOUT+++`
endif::add-copy-button-to-env-var[]
-- a|
long
|`0`
a| [[quarkus-log-handler-splunk_quarkus-log-handler-splunk-readTimeout]]`link:#quarkus-log-handler-splunk_quarkus-log-handler-splunk-readTimeout[quarkus.log.handler.splunk.readTimeout]`
[.description]
--
Sets the default read timeout for new connections in milliseconds.
ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LOG_HANDLER_SPLUNK_READTIMEOUT+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LOG_HANDLER_SPLUNK_READTIMEOUT+++`
endif::add-copy-button-to-env-var[]
-- a|
long
|`10000`
a| [[quarkus-log-handler-splunk_quarkus-log-handler-splunk-writeTimeout]]`link:#quarkus-log-handler-splunk_quarkus-log-handler-splunk-writeTimeout[quarkus.log.handler.splunk.writeTimeout]`
[.description]
--
Sets the default write timeout for new connections in milliseconds.
ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LOG_HANDLER_SPLUNK_WRITETIMEOUT+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LOG_HANDLER_SPLUNK_WRITETIMEOUT+++`
endif::add-copy-button-to-env-var[]
-- a|
long
|`10000`
a| [[quarkus-log-handler-splunk_quarkus-log-handler-splunk-terminationTimeout]]`link:#quarkus-log-handler-splunk_quarkus-log-handler-splunk-terminationTimeout[quarkus.log.handler.splunk.terminationTimeout]`
[.description]
--
Sets the default termination timeout during a flush in milliseconds.
ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_LOG_HANDLER_SPLUNK_TERMINATIONTIMEOUT+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_LOG_HANDLER_SPLUNK_TERMINATIONTIMEOUT+++`
endif::add-copy-button-to-env-var[]
-- a|
long
|`0`
|===
ifndef::no-duration-note[]
[NOTE]
Expand All @@ -1083,5 +1172,4 @@ In other cases, the simplified format is translated to the `java.time.Duration`
* If the value is a number followed by `h`, `m`, or `s`, it is prefixed with `PT`.
* If the value is a number followed by `d`, it is prefixed with `P`.
====
endif::no-duration-note[]
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.util.function.BooleanSupplier;
import java.util.logging.Level;

import com.splunk.logging.HttpEventCollectorSender;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;

Expand Down Expand Up @@ -251,4 +253,33 @@ public enum SerializationFormat {
FLAT
}

/**
* Sets the default connect timeout for new connections in milliseconds.
*/
@ConfigItem(defaultValue = "3000")
public long connectTimeout = HttpEventCollectorSender.TimeoutSettings.DEFAULT_CONNECT_TIMEOUT;

/**
* Sets the default timeout for complete calls in milliseconds.
*/
@ConfigItem(defaultValue = "0")
public long callTimeout = HttpEventCollectorSender.TimeoutSettings.DEFAULT_CALL_TIMEOUT;

/**
* Sets the default read timeout for new connections in milliseconds.
*/
@ConfigItem(defaultValue = "10000")
public long readTimeout = HttpEventCollectorSender.TimeoutSettings.DEFAULT_READ_TIMEOUT;

/**
* Sets the default write timeout for new connections in milliseconds.
*/
@ConfigItem(defaultValue = "10000")
public long writeTimeout = HttpEventCollectorSender.TimeoutSettings.DEFAULT_WRITE_TIMEOUT;

/**
* Sets the default termination timeout during a flush in milliseconds.
*/
@ConfigItem(defaultValue = "0")
public long terminationTimeout = HttpEventCollectorSender.TimeoutSettings.DEFAULT_TERMINATION_TIMEOUT;
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ static HttpEventCollectorSender createSender(SplunkHandlerConfig config) {
if (config.raw || config.serialization == SplunkHandlerConfig.SerializationFormat.RAW) {
type = "Raw";
}

HttpEventCollectorSender.TimeoutSettings rto = null;
if ((config.connectTimeout != HttpEventCollectorSender.TimeoutSettings.DEFAULT_CONNECT_TIMEOUT)
|| (config.callTimeout != HttpEventCollectorSender.TimeoutSettings.DEFAULT_CALL_TIMEOUT) ||
(config.readTimeout != HttpEventCollectorSender.TimeoutSettings.DEFAULT_READ_TIMEOUT)
|| (config.writeTimeout != HttpEventCollectorSender.TimeoutSettings.DEFAULT_WRITE_TIMEOUT) ||
(config.terminationTimeout != HttpEventCollectorSender.TimeoutSettings.DEFAULT_TERMINATION_TIMEOUT)) {
rto = new HttpEventCollectorSender.TimeoutSettings(config.connectTimeout, config.callTimeout,
config.readTimeout, config.writeTimeout, config.terminationTimeout);
}
// Timeout settings is not used and passing a null is correct regarding the code
HttpEventCollectorSender sender = new HttpEventCollectorSender(
config.url,
Expand All @@ -93,7 +103,7 @@ static HttpEventCollectorSender createSender(SplunkHandlerConfig config) {
config.batchSizeCount,
config.batchSizeBytes,
config.sendMode.name().toLowerCase(),
buildMetadata(config), null);
buildMetadata(config), rto);
if (config.serialization == SplunkHandlerConfig.SerializationFormat.FLAT) {
SplunkFlatEventSerializer serializer = new SplunkFlatEventSerializer(config.metadataSeverityFieldName);
sender.setEventHeaderSerializer(serializer);
Expand Down

0 comments on commit 2d2cdd3

Please sign in to comment.