use of zipkin2.Call.propagateIfFatal in project zipkin by openzipkin.
the class ComponentHealth method ofComponent.
static ComponentHealth ofComponent(Component component) {
Throwable t = null;
try {
CheckResult check = component.check();
if (!check.ok())
t = check.error();
} catch (Throwable unexpected) {
Call.propagateIfFatal(unexpected);
t = unexpected;
}
if (t == null)
return new ComponentHealth(component.toString(), STATUS_UP, null);
String message = t.getMessage();
String error = t.getClass().getName() + (message != null ? ": " + message : "");
return new ComponentHealth(component.toString(), STATUS_DOWN, error);
}
use of zipkin2.Call.propagateIfFatal in project zipkin by openzipkin.
the class ElasticsearchStorage method ensureIndexTemplatesAndClusterReady.
/**
* This allows the health check to display problems, such as access, installing the index
* template. It also helps reduce traffic sent to nodes still initializing (when guarded on the
* check result). Finally, this reads the cluster health of the index as it can go down after the
* one-time initialization passes.
*/
CheckResult ensureIndexTemplatesAndClusterReady(String index) {
try {
// ensure the version is available (even if we already cached it)
version();
// called only once, so we have to double-check health
ensureIndexTemplates();
AggregatedHttpRequest request = AggregatedHttpRequest.of(GET, "/_cluster/health/" + index);
CheckResult result = http().newCall(request, READ_STATUS, "get-cluster-health").execute();
if (result == null)
throw new IllegalArgumentException("No content reading cluster health");
return result;
} catch (Throwable e) {
Call.propagateIfFatal(e);
// Unwrap any IOException from the first call to ensureIndexTemplates()
if (e instanceof RejectedExecutionException || e instanceof UncheckedIOException) {
e = e.getCause();
}
return CheckResult.failed(e);
}
}
use of zipkin2.Call.propagateIfFatal in project zipkin by openzipkin.
the class KafkaCollector method check.
@Override
public CheckResult check() {
try {
// check the kafka workers didn't quit
CheckResult failure = kafkaWorkers.failure.get();
if (failure != null)
return failure;
KafkaFuture<String> maybeClusterId = getAdminClient().describeCluster().clusterId();
maybeClusterId.get(1, TimeUnit.SECONDS);
return CheckResult.OK;
} catch (Throwable e) {
Call.propagateIfFatal(e);
return CheckResult.failed(e);
}
}
use of zipkin2.Call.propagateIfFatal in project zipkin by openzipkin.
the class RabbitMQCollector method check.
@Override
public CheckResult check() {
try {
start();
CheckResult failure = connection.failure.get();
if (failure != null)
return failure;
return CheckResult.OK;
} catch (Throwable e) {
Call.propagateIfFatal(e);
return CheckResult.failed(e);
}
}
Aggregations