Skip to content

Commit 0baae69

Browse files
Kamil Bieleckiwkl3nk
authored andcommitted
feat(logs): Add default timeout values to Loki HTTP client
Signed-off-by: Kamil Bielecki <[email protected]>
1 parent 9fec17e commit 0baae69

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

logaccess/loki/src/main/kotlin/LokiLogFileProvider.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ class LokiLogFileProvider(
6262
/** The header to define the tenant ID in multi-tenant mode. */
6363
private const val TENANT_HEADER = "X-Scope-OrgID"
6464

65+
/** Default value for HTTP client timeout in seconds */
66+
private const val HTTP_CLIENT_DEFAULT_TIMEOUT_SEC = 30
67+
6568
private val logger = LoggerFactory.getLogger(LokiLogFileProvider::class.java)
6669

6770
/**
@@ -195,10 +198,11 @@ class LokiLogFileProvider(
195198
}
196199
}
197200

198-
config.timeoutSec?.also { timeout ->
199-
install(HttpTimeout) {
200-
requestTimeoutMillis = timeout * 1000L
201-
}
201+
install(HttpTimeout) {
202+
val httpClientTimeoutMillis = (config.timeoutSec ?: HTTP_CLIENT_DEFAULT_TIMEOUT_SEC) * 1000L
203+
requestTimeoutMillis = httpClientTimeoutMillis
204+
connectTimeoutMillis = httpClientTimeoutMillis
205+
socketTimeoutMillis = httpClientTimeoutMillis
202206
}
203207

204208
expectSuccess = true

0 commit comments

Comments
 (0)