Search in sources :

Example 6 with Metric

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);
        }
    }
}
Also used : ErrorHit(com.yahoo.search.result.ErrorHit) Metric(com.yahoo.jdisc.Metric) ErrorMessage(com.yahoo.search.result.ErrorMessage)

Example 7 with Metric

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);
}
Also used : MetricConsumer(com.yahoo.jdisc.application.MetricConsumer) Metric(com.yahoo.jdisc.Metric) Test(org.junit.Test)

Example 8 with Metric

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());
}
Also used : Metric(com.yahoo.jdisc.Metric) ActiveContainerMetrics(com.yahoo.jdisc.statistics.ActiveContainerMetrics) Test(org.junit.Test)

Example 9 with Metric

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);
}
Also used : Injector(com.google.inject.Injector) Metric(com.yahoo.jdisc.Metric) Test(org.junit.Test)

Example 10 with Metric

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());
}
Also used : Injector(com.google.inject.Injector) Metric(com.yahoo.jdisc.Metric) CountDownLatch(java.util.concurrent.CountDownLatch) AbstractModule(com.google.inject.AbstractModule) Test(org.junit.Test)

Aggregations

Metric (com.yahoo.jdisc.Metric)11 Test (org.junit.Test)10 AbstractModule (com.google.inject.AbstractModule)3 Injector (com.google.inject.Injector)3 Timer (com.yahoo.jdisc.Timer)2 MetricConsumer (com.yahoo.jdisc.application.MetricConsumer)2 Map (java.util.Map)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SlobroksConfig (com.yahoo.cloud.config.SlobroksConfig)1 ZookeepersConfig (com.yahoo.cloud.config.ZookeepersConfig)1 Vtag (com.yahoo.component.Vtag)1 ApplicationMetadataConfig (com.yahoo.container.core.ApplicationMetadataConfig)1 HealthMonitorConfig (com.yahoo.container.jdisc.config.HealthMonitorConfig)1 Response (com.yahoo.jdisc.Response)1 ContainerBuilder (com.yahoo.jdisc.application.ContainerBuilder)1 BufferedContentChannel (com.yahoo.jdisc.handler.BufferedContentChannel)1 ContentChannel (com.yahoo.jdisc.handler.ContentChannel)1 ResponseHandler (com.yahoo.jdisc.handler.ResponseHandler)1 ActiveContainerMetrics (com.yahoo.jdisc.statistics.ActiveContainerMetrics)1