Package codes.grow.packages.tempo
Class TempoClient
java.lang.Object
codes.grow.packages.tempo.TempoClient
- All Implemented Interfaces:
AutoCloseable
Client for Grafana Tempo's HTTP API (port 3200): health, ping, version and the query API through
query(). Spans are sent with TempoTracing.initTracing(codes.grow.packages.tempo.TempoTracingConfig) (OTLP).
try (TempoClient client = TempoClient.fromEnv()) {
Optional<Trace> trace = client.query().getTrace(traceId);
}
Implements SPEC section 2.4. Thread-safe; create one per endpoint and close it when done.
Every I/O method has a blocking form and an …Async form returning CompletableFuture.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder that configures and creates a client in one chain. -
Method Summary
Modifier and TypeMethodDescriptionstatic TempoClient.Builderbuilder()Starts a client builder.Build information (GET /api/status/buildinfo); same asquery().buildInfo().AsynchronousbuildInfo().voidclose()Closes registered resources and releases connections; later calls fail withCancelledException.config()Returns the configuration.static TempoClientcreate(TempoConfig config) Creates a client.echo()GET /api/echo→"echo"; same asquery().echo().Asynchronousecho().static TempoClientfromEnv()Creates a client fromGROW_GRAFANA_TEMPO_*, thenTEMPO_URL,TEMPO_TENANT_IDand theGROW_TEMPO_*aliases.health()Readiness:GET /ready(no tenant needed).Asynchronoushealth().booleanisClosed()Returns whetherclose()was called.ping()Tenant-aware round trip:GET /api/v2/search/tags?scope=intrinsic.Asynchronousping().query()Query API (getTrace,search,searchTags,traceQLMetrics, …) sharing this client.booleanready()GET /ready→ true when ready, false while starting; throws on network errors.Asynchronousready().voidregister(AutoCloseable resource) Registers a resource (for example aTracingHandle) closed with the client.Server version ("3.1.1") from/api/status/buildinfo, falling back to the text of/status/version.AsynchronousserverVersion().toString()Returns the HTTP transport, for service modules built on this client.
-
Method Details
-
create
Creates a client.- Parameters:
config- configuration- Returns:
- a new client
- Throws:
ConfigException- when the configuration, TLS or proxy settings are invalid
-
fromEnv
Creates a client fromGROW_GRAFANA_TEMPO_*, thenTEMPO_URL,TEMPO_TENANT_IDand theGROW_TEMPO_*aliases.- Returns:
- a new client
-
builder
Starts a client builder.- Returns:
- a new builder
-
config
Returns the configuration.- Returns:
- the configuration
-
transport
Returns the HTTP transport, for service modules built on this client.- Returns:
- the transport
-
query
Query API (getTrace,search,searchTags,traceQLMetrics, …) sharing this client.- Returns:
- the query client
-
register
Registers a resource (for example aTracingHandle) closed with the client.- Parameters:
resource- the resource
-
health
Readiness:GET /ready(no tenant needed).ready→ healthy, statusok; HTTP 503 while Tempo starts (or any other answer) →unhealthywithdetails.reason; network errors →unreachable. Never throws for an unhealthy or unreachable service.- Returns:
- the health status
- Throws:
CancelledException- when interrupted or closed
-
healthAsync
Asynchronoushealth().- Returns:
- a future with the health status
-
ping
Tenant-aware round trip:GET /api/v2/search/tags?scope=intrinsic. A multi-tenant Tempo without a tenant →AuthenticationException("tenant required").- Returns:
- the latency
- Throws:
AuthenticationException- when the tenant is missing or a proxy rejects the credentials
-
pingAsync
Asynchronousping().- Returns:
- a future with the latency
-
serverVersion
Server version ("3.1.1") from/api/status/buildinfo, falling back to the text of/status/version. A leadingvis removed.- Returns:
- the version string
- Throws:
UnsupportedException- when the server reports none
-
serverVersionAsync
AsynchronousserverVersion().- Returns:
- a future with the version
-
buildInfo
Build information (GET /api/status/buildinfo); same asquery().buildInfo().- Returns:
- build information
-
buildInfoAsync
AsynchronousbuildInfo().- Returns:
- future build information
-
echo
GET /api/echo→"echo"; same asquery().echo().- Returns:
- the echoed text
-
echoAsync
Asynchronousecho().- Returns:
- future text
-
ready
public boolean ready()GET /ready→ true when ready, false while starting; throws on network errors. Same asquery().ready().- Returns:
- readiness
-
readyAsync
Asynchronousready().- Returns:
- future readiness
-
isClosed
public boolean isClosed()Returns whetherclose()was called.- Returns:
- true once closed
-
close
public void close()Closes registered resources and releases connections; later calls fail withCancelledException. Idempotent.- Specified by:
closein interfaceAutoCloseable
-
toString
-