Class DatadogApmConfig.Builder

java.lang.Object
codes.grow.packages.datadogapm.DatadogApmConfig.Builder
Enclosing class:
DatadogApmConfig

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

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

  • Method Details

    • fromEnv

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

      public DatadogApmConfig.Builder url(String url)
      Sets the Agent trace intake URL (default http://127.0.0.1:8126).
      Parameters:
      url - http or https URL
      Returns:
      this builder
    • otlpEndpoint

      public DatadogApmConfig.Builder otlpEndpoint(String otlpEndpoint)
      Sets the OTLP endpoint of the Agent. HTTP: a base URL (http://agent:4318; /v1/traces is appended when the URL has no path) or the full traces URL; gRPC: http://agent:4317. Unset: the host of url(String) with port 4318 or 4317.
      Parameters:
      otlpEndpoint - endpoint URL
      Returns:
      this builder
    • protocol

      Sets the OTLP protocol (HTTP_PROTOBUF by default, or GRPC).
      Parameters:
      protocol - protocol
      Returns:
      this builder
    • serviceName

      public DatadogApmConfig.Builder serviceName(String serviceName)
      Sets service of unified service tagging.
      Parameters:
      serviceName - service name
      Returns:
      this builder
    • serviceVersion

      public DatadogApmConfig.Builder serviceVersion(String serviceVersion)
      Sets version of unified service tagging.
      Parameters:
      serviceVersion - version
      Returns:
      this builder
    • environment

      public DatadogApmConfig.Builder environment(String environment)
      Sets env of unified service tagging.
      Parameters:
      environment - environment
      Returns:
      this builder
    • tag

      public DatadogApmConfig.Builder tag(String key, String value)
      Adds an extra resource attribute (merged over DD_TAGS).
      Parameters:
      key - key
      value - value
      Returns:
      this builder
    • tags

      Adds extra resource attributes.
      Parameters:
      tags - tags
      Returns:
      this builder
    • apiKey

      public DatadogApmConfig.Builder apiKey(Secret apiKey)
      Sets the Datadog API key (query API only).
      Parameters:
      apiKey - key
      Returns:
      this builder
    • apiKey

      public DatadogApmConfig.Builder apiKey(String apiKey)
      Sets the Datadog API key (query API only).
      Parameters:
      apiKey - key
      Returns:
      this builder
    • appKey

      public DatadogApmConfig.Builder appKey(Secret appKey)
      Sets the Datadog application key with apm_read (query API only).
      Parameters:
      appKey - key
      Returns:
      this builder
    • appKey

      public DatadogApmConfig.Builder appKey(String appKey)
      Sets the Datadog application key with apm_read (query API only).
      Parameters:
      appKey - key
      Returns:
      this builder
    • site

      public DatadogApmConfig.Builder site(String site)
      Sets the Datadog site, e.g. datadoghq.eu (default datadoghq.com).
      Parameters:
      site - site host name
      Returns:
      this builder
    • apiUrl

      public DatadogApmConfig.Builder apiUrl(String apiUrl)
      Sets the query API base URL (default https://api.<site>).
      Parameters:
      apiUrl - URL
      Returns:
      this builder
    • connectTimeout

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

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

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

      public DatadogApmConfig.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 DatadogApmConfig.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 DatadogApmConfig.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 DatadogApmConfig.Builder userAgentSuffix(String suffix)
      Sets the text appended to the User-Agent.
      Parameters:
      suffix - suffix
      Returns:
      this builder
    • hooks

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

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

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