Class BetterStackConfig.Builder

java.lang.Object
codes.grow.packages.betterstack.BetterStackConfig.Builder
Enclosing class:
BetterStackConfig

public static final class BetterStackConfig.Builder extends Object
Builder of the configuration.

Unset fields take the environment (when fromEnv(EnvReader) is called) or the default.

  • Method Details

    • fromEnv

      public BetterStackConfig.Builder fromEnv(EnvReader env)
      Fills every field that was not set explicitly from the environment: GROW_BETTER_STACK_LOGS_<NAME> first, then the vendor variables ( BETTERSTACK_INGESTING_URL, BETTERSTACK_INGESTING_HOST, BETTERSTACK_SOURCE_TOKEN, BETTERSTACK_QUERY_URL, BETTERSTACK_QUERY_HOST, BETTERSTACK_QUERY_USERNAME, BETTERSTACK_QUERY_PASSWORD, BETTERSTACK_SOURCE_TABLE).
      Parameters:
      env - environment reader
      Returns:
      this builder
      Throws:
      ConfigException - when a variable holds an invalid value
    • url

      Sets the ingest base URL: the source's ingesting host ( s1234.eu-nbg-2.betterstackdata.com becomes https://…).
      Parameters:
      url - host or http(s) URL
      Returns:
      this builder
    • sourceToken

      public BetterStackConfig.Builder sourceToken(Secret token)
      Sets the source token (sent as Authorization: Bearer to the ingesting host only).
      Parameters:
      token - token
      Returns:
      this builder
    • sourceToken

      public BetterStackConfig.Builder sourceToken(String token)
      Sets the source token.
      Parameters:
      token - token
      Returns:
      this builder
    • queryUrl

      public BetterStackConfig.Builder queryUrl(String queryUrl)
      Sets the SQL query base URL (ClickHouse HTTP interface).
      Parameters:
      queryUrl - host or http(s) URL
      Returns:
      this builder
    • queryUsername

      public BetterStackConfig.Builder queryUsername(String username)
      Sets the SQL connection username.
      Parameters:
      username - username
      Returns:
      this builder
    • queryPassword

      public BetterStackConfig.Builder queryPassword(Secret password)
      Sets the SQL connection password (HTTP Basic, query host only).
      Parameters:
      password - password
      Returns:
      this builder
    • queryPassword

      public BetterStackConfig.Builder queryPassword(String password)
      Sets the SQL connection password.
      Parameters:
      password - password
      Returns:
      this builder
    • sourceTable

      public BetterStackConfig.Builder sourceTable(String sourceTable)
      Sets the default collection (t1234_myapp).
      Parameters:
      sourceTable - identifier
      Returns:
      this builder
    • encoding

      public BetterStackConfig.Builder encoding(IngestEncoding encoding)
      Sets the ingest body encoding (default IngestEncoding.JSON).
      Parameters:
      encoding - encoding
      Returns:
      this builder
    • connectTimeout

      public BetterStackConfig.Builder connectTimeout(Duration d)
      Sets the connect timeout (default 10 s).
      Parameters:
      d - positive duration
      Returns:
      this builder
    • requestTimeout

      public BetterStackConfig.Builder requestTimeout(Duration d)
      Sets the per-attempt timeout (default 30 s).
      Parameters:
      d - positive duration
      Returns:
      this builder
    • totalTimeout

      public BetterStackConfig.Builder totalTimeout(Duration d)
      Sets the total timeout per call including retries (default 120 s).
      Parameters:
      d - positive duration
      Returns:
      this builder
    • retry

      public BetterStackConfig.Builder retry(RetryPolicy retry)
      Sets the retry policy (default RetryPolicy.defaults()).
      Parameters:
      retry - policy
      Returns:
      this builder
    • tls

      Sets the TLS options; environment TLS variables are then ignored.
      Parameters:
      tls - options
      Returns:
      this builder
    • proxy

      public BetterStackConfig.Builder proxy(String proxy)
      Sets an explicit proxy URL; environment proxies (HTTPS_PROXY) are never used.
      Parameters:
      proxy - proxy URL
      Returns:
      this builder
    • header

      public BetterStackConfig.Builder header(String name, String value)
      Adds a header sent with every request to both hosts.
      Parameters:
      name - header name
      value - header value
      Returns:
      this builder
    • userAgentSuffix

      public BetterStackConfig.Builder userAgentSuffix(String suffix)
      Sets the text appended to the User-Agent.
      Parameters:
      suffix - suffix
      Returns:
      this builder
    • hooks

      public BetterStackConfig.Builder hooks(Hooks hooks)
      Sets request hooks.
      Parameters:
      hooks - hooks
      Returns:
      this builder
    • logger

      public BetterStackConfig.Builder logger(Logger logger)
      Sets the logger (default silent).
      Parameters:
      logger - logger
      Returns:
      this builder
    • build

      public BetterStackConfig build()
      Builds and validates the configuration.
      Returns:
      the configuration
      Throws:
      ConfigException - when a rule is violated