Class TempoConfig

java.lang.Object
codes.grow.packages.tempo.TempoConfig

public final class TempoConfig extends Object
Immutable configuration of a TempoClient (SPEC section 2.2).

Build one with builder() or read it from the environment with fromEnv(). Precedence: explicit builder value > SDK variable (EnvReader.DEFAULT_PREFIX + name) > vendor variables > default. toString() never prints credentials.

Tempo has no authentication of its own: put an authenticating reverse proxy in front of it and pass its credentials with TempoConfig.Builder.header(String, String) (sensitive headers are redacted everywhere). Environment: GROW_GRAFANA_TEMPO_URL, then TEMPO_URL and GROW_TEMPO_URL; GROW_GRAFANA_TEMPO_TENANT_ID, then TEMPO_TENANT_ID and GROW_TEMPO_TENANT_ID; GROW_GRAFANA_TEMPO_TOKEN, then GROW_TEMPO_TOKEN; the common SPEC variables (GROW_GRAFANA_TEMPO_REQUEST_TIMEOUT, …) with GROW_TEMPO_* aliases for TLS and proxy.

  • Field Details

    • DEFAULT_URL

      public static final String DEFAULT_URL
      Default endpoint of the query API (HTTP port 3200).
      See Also:
    • TENANT_HEADER

      public static final String TENANT_HEADER
      Header that selects the tenant on a multi-tenant Tempo (query and OTLP ingest; gRPC metadata x-scope-orgid). A single-tenant Tempo ignores it.
      See Also:
  • Method Details

    • builder

      public static TempoConfig.Builder builder()
      Starts an empty builder (every field at its default).
      Returns:
      a new builder
    • fromEnv

      public static TempoConfig fromEnv()
      Reads the configuration from the process environment.
      Returns:
      the validated configuration
      Throws:
      ConfigException - when a variable holds an invalid value (the message names the variable, never the value)
    • fromEnv

      public static TempoConfig fromEnv(Map<String,String> env)
      Reads the configuration from an explicit variable map (tests).
      Parameters:
      env - variable map
      Returns:
      the validated configuration
    • validate

      public void validate()
      Checks URL scheme, positive timeouts, retry limits and TLS pairs.
      Throws:
      ConfigException - when a rule is violated
    • validateTenantId

      public static void validateTenantId(String tenantId)
      Checks a Tempo tenant id: per tenant 1-150 characters of letters, digits and !-_.*'() (not . or ..); | joins tenants of a federated query.
      Parameters:
      tenantId - tenant id, or null (no tenant)
      Throws:
      ConfigException - when the id is invalid (the message never repeats the value)
    • toTransportConfig

      public TransportConfig toTransportConfig()
      Translates the common fields into transport settings.
      Returns:
      the transport configuration
    • url

      public String url()
      Returns the endpoint base URL.
      Returns:
      the URL
    • tenantId

      public Optional<String> tenantId()
      Returns the tenant sent as X-Scope-OrgID on every query call.
      Returns:
      the tenant id, or empty (no header)
    • token

      public Optional<Secret> token()
      Returns the bearer token for an authenticating reverse proxy (Tempo itself has no auth).
      Returns:
      the token, or empty
    • connectTimeout

      public Duration connectTimeout()
      Returns the connect timeout.
      Returns:
      the timeout
    • requestTimeout

      public Duration requestTimeout()
      Returns the per-attempt timeout.
      Returns:
      the timeout
    • totalTimeout

      public Duration totalTimeout()
      Returns the total timeout per call including retries.
      Returns:
      the timeout
    • retry

      public RetryPolicy retry()
      Returns the retry policy.
      Returns:
      the policy
    • tls

      public TlsOptions tls()
      Returns the TLS options.
      Returns:
      the options
    • proxy

      public Optional<String> proxy()
      Returns the explicit proxy URL.
      Returns:
      the proxy, or empty
    • headers

      public Map<String,String> headers()
      Returns the extra request headers.
      Returns:
      immutable map
    • userAgentSuffix

      public Optional<String> userAgentSuffix()
      Returns the user agent suffix.
      Returns:
      the suffix, or empty
    • hooks

      public Hooks hooks()
      Returns the hooks.
      Returns:
      the hooks
    • logger

      public Logger logger()
      Returns the logger.
      Returns:
      the logger
    • toString

      public String toString()
      Overrides:
      toString in class Object