Class TempoConfig.Builder

java.lang.Object
codes.grow.packages.tempo.TempoConfig.Builder
Enclosing class:
TempoConfig

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

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

  • Method Details

    • fromEnv

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

      public TempoConfig.Builder url(String url)
      Sets the endpoint base URL.
      Parameters:
      url - http or https URL
      Returns:
      this builder
    • tenantId

      public TempoConfig.Builder tenantId(String tenantId)
      Sets the tenant sent as X-Scope-OrgID on every query call. Required by a multi-tenant Tempo, ignored by a single-tenant one; "a|b" runs a federated query.
      Parameters:
      tenantId - tenant id or null
      Returns:
      this builder
    • token

      public TempoConfig.Builder token(Secret token)
      Sets a bearer token sent as Authorization: Bearer <token>; only useful behind an authenticating reverse proxy (Tempo itself has no authentication).
      Parameters:
      token - token or null
      Returns:
      this builder
    • token

      public TempoConfig.Builder token(String token)
      Sets a bearer token for an authenticating reverse proxy.
      Parameters:
      token - token or null
      Returns:
      this builder
    • connectTimeout

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

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

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

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

      public TempoConfig.Builder tls(TlsOptions tls)
      Sets the TLS options; environment TLS variables are then ignored.
      Parameters:
      tls - options
      Returns:
      this builder
    • proxy

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

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

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

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