Class CollectorHealthClient
java.lang.Object
codes.grow.packages.otelcollector.CollectorHealthClient
- All Implemented Interfaces:
AutoCloseable
Health of an OpenTelemetry Collector:
GET {healthUrl} (health_check extension,
port 13133) and, when that endpoint is unreachable (stock Grow stacks bind it to localhost),
GET {zpagesUrl}/debug/servicez (port 55679). Also reads the collector version.
Admin endpoints are unauthenticated: the configured export headers are never sent to them.
Thread-safe; close it when done (a health client obtained from OtelCollectorClient.collectorHealth() is closed with the client).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DurationPause between probes ofwaitUntilReady().static final DurationDefault deadline ofwaitUntilReady(). -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Releases connections.config()Returns the configuration.static CollectorHealthClientcreate(OtelCollectorConfig config) Creates a health client.static CollectorHealthClientfromEnv()Creates a health client from the environment (seeOtelCollectorConfig.fromEnv()).health()Collector health.Asynchronoushealth().parseServicezVersion(String html) Parses the collector version from the zpages/debug/servicezHTML.parseTargetInfoVersion(String metrics) Parsesservice_versionof the Prometheustarget_infoseries.Collector version: the zpages/debug/servicez"Version" row (works on stock stacks), elseservice_versionoftarget_infoatOtelCollectorConfig.telemetryUrl().AsynchronousserverVersion().Pollshealth()until the collector is healthy, for at mostDEFAULT_READY_TIMEOUT.waitUntilReady(Duration timeout) Pollshealth()until the collector is healthy.waitUntilReadyAsync(Duration timeout) AsynchronouswaitUntilReady(Duration): no thread blocks between probes.
-
Field Details
-
DEFAULT_READY_TIMEOUT
Default deadline ofwaitUntilReady(). -
DEFAULT_READY_INTERVAL
Pause between probes ofwaitUntilReady().
-
-
Method Details
-
create
Creates a health client.- Parameters:
config- validated configuration- Returns:
- a new client
-
fromEnv
Creates a health client from the environment (seeOtelCollectorConfig.fromEnv()).- Returns:
- a new client
-
config
Returns the configuration.- Returns:
- the configuration
-
parseServicezVersion
Parses the collector version from the zpages/debug/servicezHTML.- Parameters:
html- page- Returns:
- the version, or empty
-
parseTargetInfoVersion
Parsesservice_versionof the Prometheustarget_infoseries.- Parameters:
metrics- exposition text- Returns:
- the version, or empty
-
health
Collector health.200 {"status":"Server available",…}→healthy=true, status="ok"with detailssource=health_check,vendorStatus,upSince,uptime; another status (503while starting or stopping) →unhealthy; unreachable → zpages fallback (details.source=zpages), elseunreachable. Never throws for an unhealthy or unreachable collector.- Returns:
- the status
- Throws:
CancelledException- when interrupted or closed
-
healthAsync
Asynchronoushealth().- Returns:
- a future with the status (failed only for cancellation and configuration errors)
-
waitUntilReady
Pollshealth()until the collector is healthy, for at mostDEFAULT_READY_TIMEOUT.- Returns:
- the healthy status
- Throws:
TimeoutException- at the deadlineCancelledException- when interrupted
-
waitUntilReady
Pollshealth()until the collector is healthy.- Parameters:
timeout- deadline- Returns:
- the healthy status
- Throws:
TimeoutException- at the deadlineCancelledException- when interrupted
-
waitUntilReadyAsync
AsynchronouswaitUntilReady(Duration): no thread blocks between probes.- Parameters:
timeout- deadline- Returns:
- a future with the healthy status, failed with
TimeoutException
-
serverVersion
Collector version: the zpages/debug/servicez"Version" row (works on stock stacks), elseservice_versionoftarget_infoatOtelCollectorConfig.telemetryUrl().- Returns:
- the version, such as
0.165.0 - Throws:
UnsupportedException- when neither source answers with a version
-
serverVersionAsync
AsynchronousserverVersion().- Returns:
- a future with the version
-
close
public void close()Releases connections. Idempotent.- Specified by:
closein interfaceAutoCloseable
-