Class DatadogLogsConfig.Builder

java.lang.Object
codes.grow.packages.datadoglogs.DatadogLogsConfig.Builder
Enclosing class:
DatadogLogsConfig

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

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

  • Method Details

    • fromEnv

      public DatadogLogsConfig.Builder fromEnv(EnvReader reader)
      Fills every field that was not set explicitly from the environment.
      Parameters:
      reader - environment reader
      Returns:
      this builder
      Throws:
      ConfigException - when a variable holds an invalid value
    • apiKey

      public DatadogLogsConfig.Builder apiKey(Secret apiKey)
      Sets the Datadog API key (required by every call).
      Parameters:
      apiKey - key
      Returns:
      this builder
    • apiKey

      public DatadogLogsConfig.Builder apiKey(String apiKey)
      Sets the Datadog API key (required by every call).
      Parameters:
      apiKey - key
      Returns:
      this builder
    • appKey

      public DatadogLogsConfig.Builder appKey(Secret appKey)
      Sets the Datadog application key (query API only; never sent to the intake).
      Parameters:
      appKey - key
      Returns:
      this builder
    • appKey

      public DatadogLogsConfig.Builder appKey(String appKey)
      Sets the Datadog application key (query API only; never sent to the intake).
      Parameters:
      appKey - key
      Returns:
      this builder
    • site

      public DatadogLogsConfig.Builder site(String site)
      Sets the Datadog site, for example datadoghq.eu (default datadoghq.com).
      Parameters:
      site - site, see DatadogSites.SITES
      Returns:
      this builder
    • url

      Sets one base URL for both the intake and the API (tests, proxies, fakeintake).
      Parameters:
      url - http or https URL
      Returns:
      this builder
    • intakeUrl

      public DatadogLogsConfig.Builder intakeUrl(String intakeUrl)
      Overrides the logs intake base URL.
      Parameters:
      intakeUrl - http or https URL
      Returns:
      this builder
    • apiUrl

      public DatadogLogsConfig.Builder apiUrl(String apiUrl)
      Overrides the API base URL.
      Parameters:
      apiUrl - http or https URL
      Returns:
      this builder
    • service

      public DatadogLogsConfig.Builder service(String service)
      Sets the default service (used when a record has no service.name resource).
      Parameters:
      service - service name
      Returns:
      this builder
    • env

      Sets the environment, sent as tag env:<value>.
      Parameters:
      env - environment
      Returns:
      this builder
    • version

      public DatadogLogsConfig.Builder version(String version)
      Sets the version, sent as tag version:<value>.
      Parameters:
      version - version
      Returns:
      this builder
    • tags

      public DatadogLogsConfig.Builder tags(List<String> tags)
      Replaces the tags added to every log.
      Parameters:
      tags - key:value strings
      Returns:
      this builder
    • tags

      public DatadogLogsConfig.Builder tags(String tags)
      Replaces the tags from one string separated by commas or spaces.
      Parameters:
      tags - tag list text
      Returns:
      this builder
    • hostname

      public DatadogLogsConfig.Builder hostname(String hostname)
      Sets the default hostname (used when a record has no host.name resource).
      Parameters:
      hostname - host name
      Returns:
      this builder
    • source

      public DatadogLogsConfig.Builder source(String source)
      Sets the ddsource of every log (default grow-sdk).
      Parameters:
      source - source
      Returns:
      this builder
    • connectTimeout

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

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

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

      public DatadogLogsConfig.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 DatadogLogsConfig.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 DatadogLogsConfig.Builder header(String name, String value)
      Adds a header sent with every request.
      Parameters:
      name - header name
      value - header value
      Returns:
      this builder
    • userAgentSuffix

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

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

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

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