use of com.yahoo.jdisc.Metric in project vespa by vespa-engine.
the class StatisticsSearcher method incrementStatePageOnlyErrors.
/**
* Creates error metric for StateHandler only. These metrics are only exposed on /state/v1/metrics page
* and not forwarded to the log file.
*
* @param result The result to check for errors
*/
private void incrementStatePageOnlyErrors(Result result) {
if (result == null)
return;
ErrorHit error = result.hits().getErrorHit();
if (error == null)
return;
for (ErrorMessage m : error.errors()) {
int code = m.getCode();
Metric.Context c = getDimensions(m.getSource());
if (code == TIMEOUT.code) {
metric.add("error.timeout", 1, c);
} else if (code == NO_BACKENDS_IN_SERVICE.code) {
metric.add("error.backends_oos", 1, c);
} else if (code == ERROR_IN_PLUGIN.code) {
metric.add("error.plugin_failure", 1, c);
} else if (code == BACKEND_COMMUNICATION_ERROR.code) {
metric.add("error.backend_communication_error", 1, c);
} else if (code == EMPTY_DOCUMENTS.code) {
metric.add("error.empty_document_summaries", 1, c);
} else if (code == ILLEGAL_QUERY.code) {
metric.add("error.illegal_query", 1, c);
} else if (code == INVALID_QUERY_PARAMETER.code) {
metric.add("error.invalid_query_parameter", 1, c);
} else if (code == INTERNAL_SERVER_ERROR.code) {
metric.add("error.internal_server_error", 1, c);
} else if (code == SERVER_IS_MISCONFIGURED.code) {
metric.add("error.misconfigured_server", 1, c);
} else if (code == INVALID_QUERY_TRANSFORMATION.code) {
metric.add("error.invalid_query_transformation", 1, c);
} else if (code == RESULT_HAS_ERRORS.code) {
metric.add("error.result_with_errors", 1, c);
} else if (code == UNSPECIFIED.code) {
metric.add("error.unspecified", 1, c);
}
}
}
use of com.yahoo.jdisc.Metric in project vespa by vespa-engine.
the class MetricProviderTest method requireThatMetricProviderDelegatesToConsumerFactory.
@Test
public void requireThatMetricProviderDelegatesToConsumerFactory() {
MetricConsumer consumer = Mockito.mock(MetricConsumer.class);
MetricProvider provider = MetricProviders.newInstance(consumer);
Metric metric = provider.get();
assertNotNull(metric);
Metric.Context fooCtx = Mockito.mock(Metric.Context.class);
metric.add("foo", 6, fooCtx);
metric.set("foo", 9, fooCtx);
Mockito.verify(consumer, Mockito.times(1)).add("foo", 6, fooCtx);
Mockito.verify(consumer, Mockito.times(1)).set("foo", 9, fooCtx);
}
use of com.yahoo.jdisc.Metric in project vespa by vespa-engine.
the class MetricUpdaterTest method metrics_are_updated_in_scheduler_cycle.
@Test
public void metrics_are_updated_in_scheduler_cycle() throws InterruptedException {
Metric metric = mock(Metric.class);
ActiveContainerMetrics activeContainerMetrics = mock(ActiveContainerMetrics.class);
new MetricUpdater(new MockScheduler(), metric, activeContainerMetrics);
verify(activeContainerMetrics, times(1)).emitMetrics(any());
verify(metric, times(8)).set(anyString(), any(), any());
}
use of com.yahoo.jdisc.Metric in project vespa by vespa-engine.
the class MetricImplTestCase method requireThatConsumerIsOptional.
@Test
public void requireThatConsumerIsOptional() {
Injector injector = Guice.createInjector();
Metric metric = injector.getInstance(Metric.class);
metric.set("foo", 6, null);
metric.add("foo", 9, null);
}
use of com.yahoo.jdisc.Metric in project vespa by vespa-engine.
the class MetricImplTestCase method requireThatWorkerMetricHasPrecedence.
@Test
public void requireThatWorkerMetricHasPrecedence() throws InterruptedException {
final MyConsumer globalConsumer = new MyConsumer();
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(MetricConsumer.class).toInstance(globalConsumer);
}
});
Metric metric = injector.getInstance(Metric.class);
MyConsumer localConsumer = new MyConsumer();
localConsumer.latchRef.set(new CountDownLatch(1));
new ContainerThread(new SetTask(metric, "foo", 6), localConsumer).start();
localConsumer.latchRef.get().await(600, TimeUnit.SECONDS);
assertEquals(6, localConsumer.map.get("foo").intValue());
assertTrue(globalConsumer.map.isEmpty());
localConsumer.latchRef.set(new CountDownLatch(1));
new ContainerThread(new AddTask(metric, "foo", 9), localConsumer).start();
localConsumer.latchRef.get().await(600, TimeUnit.SECONDS);
assertEquals(15, localConsumer.map.get("foo").intValue());
assertTrue(globalConsumer.map.isEmpty());
}
Aggregations