use of zipkin2.CheckResult.failed in project zipkin by openzipkin.
the class ForwardingStorageComponentTest method delegatesCheck.
@Test
public void delegatesCheck() {
CheckResult down = CheckResult.failed(new RuntimeException("failed"));
when(delegate.check()).thenReturn(down);
assertThat(forwarder.check()).isEqualTo(down);
verify(delegate).check();
}
use of zipkin2.CheckResult.failed in project zipkin by openzipkin.
the class ComponentHealthTest method addsMessageToDetails.
@Test
public void addsMessageToDetails() {
ComponentHealth health = ComponentHealth.ofComponent(new Component() {
@Override
public CheckResult check() {
return CheckResult.failed(new IOException("socket disconnect"));
}
});
assertThat(health.error).isEqualTo("java.io.IOException: socket disconnect");
}
use of zipkin2.CheckResult.failed in project zipkin by openzipkin.
the class ComponentHealthTest method doesntAddNullMessageToDetails.
@Test
public void doesntAddNullMessageToDetails() {
ComponentHealth health = ComponentHealth.ofComponent(new Component() {
@Override
public CheckResult check() {
return CheckResult.failed(ClosedSessionException.get());
}
});
assertThat(health.error).isEqualTo("com.linecorp.armeria.common.ClosedSessionException");
}
use of zipkin2.CheckResult.failed 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.CheckResult.failed 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);
}
}
Aggregations