summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryngveaasheim <yngve@yahooinc.com>2023-05-09 11:12:31 +0200
committeryngveaasheim <yngve@yahooinc.com>2023-05-09 11:12:31 +0200
commita06981939635e3d3b363d101e96abeadd38f9d13 (patch)
treea7ec1c47735c8b55cb7e7ba2b09f332fd4b6f37f
parent576c99377745221ea70472b55ff2b527bc6753a5 (diff)
Use metric enums more places.
-rw-r--r--container-core/src/main/java/com/yahoo/container/core/HandlerMetricContextUtil.java5
-rw-r--r--metrics/src/main/java/ai/vespa/metrics/ConfigServerMetrics.java15
-rw-r--r--metrics/src/main/java/ai/vespa/metrics/ContainerMetrics.java1
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MaintenanceDeployment.java5
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZkStatusService.java13
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java35
6 files changed, 46 insertions, 28 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/core/HandlerMetricContextUtil.java b/container-core/src/main/java/com/yahoo/container/core/HandlerMetricContextUtil.java
index b7a5732561f..1872f06b30f 100644
--- a/container-core/src/main/java/com/yahoo/container/core/HandlerMetricContextUtil.java
+++ b/container-core/src/main/java/com/yahoo/container/core/HandlerMetricContextUtil.java
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.core;
+import ai.vespa.metrics.ContainerMetrics;
import com.yahoo.jdisc.Metric;
import com.yahoo.jdisc.Request;
import com.yahoo.jdisc.application.BindingMatch;
@@ -19,11 +20,11 @@ import java.util.concurrent.TimeUnit;
public class HandlerMetricContextUtil {
public static void onHandle(Request request, Metric metric, Class<?> handlerClass) {
- metric.add("handled.requests", 1, contextFor(request, metric, handlerClass));
+ metric.add(ContainerMetrics.HANDLED_REQUESTS.baseName(), 1, contextFor(request, metric, handlerClass));
}
public static void onHandled(Request request, Metric metric, Class<?> handlerClass) {
- metric.set("handled.latency", request.timeElapsed(TimeUnit.MILLISECONDS), contextFor(request, metric, handlerClass));
+ metric.set(ContainerMetrics.HANDLED_LATENCY.baseName(), request.timeElapsed(TimeUnit.MILLISECONDS), contextFor(request, metric, handlerClass));
}
public static Metric.Context contextFor(Request request, Metric metric, Class<?> handlerClass) {
diff --git a/metrics/src/main/java/ai/vespa/metrics/ConfigServerMetrics.java b/metrics/src/main/java/ai/vespa/metrics/ConfigServerMetrics.java
index dba75c08aae..013c50e77cf 100644
--- a/metrics/src/main/java/ai/vespa/metrics/ConfigServerMetrics.java
+++ b/metrics/src/main/java/ai/vespa/metrics/ConfigServerMetrics.java
@@ -24,6 +24,10 @@ public enum ConfigServerMetrics implements VespaMetrics {
REMOVED_SESSIONS("configserver.removedSessions", Unit.SESSION, "Removed config sessions"),
RPC_SERVER_WORK_QUEUE_SIZE("configserver.rpcServerWorkQueueSize", Unit.ITEM, "Number of elements in the RPC server work queue"),
+ MAINTENANCE_DEPLOYMENT_TRANSIENT_FAILURE("maintenanceDeployment.transientFailure", Unit.OPERATION, "Number of maintenance deployments that failed with a transient failure"),
+ MAINTENANCE_DEPLOYMENT_FAILURE("maintenanceDeployment.failure", Unit.OPERATION, "Number of maintenance deployments that failed with a permanent failure"),
+
+
// ZooKeeper related metrics
ZK_CONNECTIONS_LOST("configserver.zkConnectionLost", Unit.CONNECTION, "Number of ZooKeeper connections lost"),
ZK_RECONNECTED("configserver.zkReconnected", Unit.CONNECTION, "Number of ZooKeeper reconnections"),
@@ -33,7 +37,16 @@ public enum ConfigServerMetrics implements VespaMetrics {
ZK_AVG_LATENCY("configserver.zkAvgLatency", Unit.MILLISECOND, "Average latency for ZooKeeper requests"), // TODO: Confirm metric name
ZK_MAX_LATENCY("configserver.zkMaxLatency", Unit.MILLISECOND, "Max latency for ZooKeeper requests"),
ZK_CONNECTIONS("configserver.zkConnections", Unit.CONNECTION, "Number of ZooKeeper connections"),
- ZK_OUTSTANDING_REQUESTS("configserver.zkOutstandingRequests", Unit.REQUEST, "Number of ZooKeeper requests in flight");
+ ZK_OUTSTANDING_REQUESTS("configserver.zkOutstandingRequests", Unit.REQUEST, "Number of ZooKeeper requests in flight"),
+
+ // Orchestrator lock metrics
+ ORCHESTRATOR_LOCK_ACQUIRE_LATENCY("orchestrator.lock.acquire-latency", Unit.SECOND, "Time to acquire zookeeper lock"),
+ ORCHESTRATOR_LOCK_ACQUIRE_SUCCESS("orchestrator.lock.acquire-success", Unit.OPERATION, "Number of times zookeeper lock has been acquired successfully"),
+ ORCHESTRATOR_LOCK_ACQUIRE_TIMEOUT("orchestrator.lock.acquire-timedout", Unit.OPERATION, "Number of times zookeeper lock couldn't be acquired within timeout"),
+ ORCHESTRATOR_LOCK_ACQUIRE("orchestrator.lock.acquire", Unit.OPERATION, "Number of attempts to acquire zookeeper lock"),
+ ORCHESTRATOR_LOCK_ACQUIRED("orchestrator.lock.acquired", Unit.OPERATION, "Number of times zookeeper lock was acquired"),
+ ORCHESTRATOR_LOCK_HOLD_LATENCY("orchestrator.lock.hold-latency", Unit.SECOND, "Time zookeeper lock was held before it was released");
+
private final String name;
private final Unit unit;
diff --git a/metrics/src/main/java/ai/vespa/metrics/ContainerMetrics.java b/metrics/src/main/java/ai/vespa/metrics/ContainerMetrics.java
index 84de1878b3f..ab3fb9b6197 100644
--- a/metrics/src/main/java/ai/vespa/metrics/ContainerMetrics.java
+++ b/metrics/src/main/java/ai/vespa/metrics/ContainerMetrics.java
@@ -91,6 +91,7 @@ public enum ContainerMetrics implements VespaMetrics {
HTTPAPI_NUM_UPDATES("httpapi_num_updates", Unit.OPERATION, "Document update operations performed"),
HTTPAPI_NUM_REMOVES("httpapi_num_removes", Unit.OPERATION, "Document remove operations performed"),
HTTPAPI_NUM_PUTS("httpapi_num_puts", Unit.OPERATION, "Document put operations performed"),
+ HTTPAPI_OPS_PER_SEC("httpapi_ops_per_sec", Unit.OPERATION_PER_SECOND, "Document operations per second"), // TODO: Remove in Vespa 9
HTTPAPI_SUCCEEDED("httpapi_succeeded", Unit.OPERATION, "Document operations that succeeded"),
HTTPAPI_FAILED("httpapi_failed", Unit.OPERATION, "Document operations that failed"),
HTTPAPI_PARSE_ERROR("httpapi_parse_error", Unit.OPERATION, "Document operations that failed due to document parse errors"),
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MaintenanceDeployment.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MaintenanceDeployment.java
index 189238a1c11..be398f6e8ad 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MaintenanceDeployment.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/MaintenanceDeployment.java
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.maintenance;
+import ai.vespa.metrics.ConfigServerMetrics;
import com.yahoo.concurrent.UncheckedTimeoutException;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.Deployer;
@@ -85,12 +86,12 @@ class MaintenanceDeployment implements Closeable {
try {
return Optional.of(step.get());
} catch (TransientException | ActivationConflictException e) {
- metric.add("maintenanceDeployment.transientFailure", 1, metric.createContext(Map.of()));
+ metric.add(ConfigServerMetrics.MAINTENANCE_DEPLOYMENT_TRANSIENT_FAILURE.baseName(), 1, metric.createContext(Map.of()));
log.log(Level.INFO, "Failed to maintenance deploy " + application + " with a transient error: " +
Exceptions.toMessageString(e));
return Optional.empty();
} catch (RuntimeException e) {
- metric.add("maintenanceDeployment.failure", 1, metric.createContext(Map.of()));
+ metric.add(ConfigServerMetrics.MAINTENANCE_DEPLOYMENT_FAILURE.baseName(), 1, metric.createContext(Map.of()));
log.log(Level.WARNING, "Exception on maintenance deploy of " + application, e);
return Optional.empty();
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZkStatusService.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZkStatusService.java
index ce68dca0cc5..2a598e62ca8 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZkStatusService.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/status/ZkStatusService.java
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.orchestrator.status;
+import ai.vespa.metrics.ConfigServerMetrics;
import com.yahoo.concurrent.UncheckedTimeoutException;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.jdisc.Metric;
@@ -173,11 +174,13 @@ public class ZkStatusService implements StatusService {
acquireEndTime = timer.currentTime();
double seconds = durationInSeconds(startTime, acquireEndTime);
// TODO: These metrics are redundant with Lock's metrics
- metric.set("orchestrator.lock.acquire-latency", seconds, metricContext);
- metric.set("orchestrator.lock.acquired", lockAcquired ? 1 : 0, metricContext);
+ metric.set(ConfigServerMetrics.ORCHESTRATOR_LOCK_ACQUIRE_LATENCY.baseName(), seconds, metricContext);
+ metric.set(ConfigServerMetrics.ORCHESTRATOR_LOCK_ACQUIRED.baseName(), lockAcquired ? 1 : 0, metricContext);
- metric.add("orchestrator.lock.acquire", 1, metricContext);
- String acquireResultMetricName = lockAcquired ? "orchestrator.lock.acquire-success" : "orchestrator.lock.acquire-timedout";
+ metric.add(ConfigServerMetrics.ORCHESTRATOR_LOCK_ACQUIRE.baseName(), 1, metricContext);
+ String acquireResultMetricName = lockAcquired
+ ? ConfigServerMetrics.ORCHESTRATOR_LOCK_ACQUIRE_SUCCESS.baseName()
+ : ConfigServerMetrics.ORCHESTRATOR_LOCK_ACQUIRE_TIMEOUT.baseName();
metric.add(acquireResultMetricName, 1, metricContext);
}
@@ -199,7 +202,7 @@ public class ZkStatusService implements StatusService {
Instant lockReleasedTime = timer.currentTime();
double seconds = durationInSeconds(acquireEndTime, lockReleasedTime);
- metric.set("orchestrator.lock.hold-latency", seconds, metricContext);
+ metric.set(ConfigServerMetrics.ORCHESTRATOR_LOCK_HOLD_LATENCY.baseName(), seconds, metricContext);
};
}
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java
index 1bb9ab4b062..0f080069ac5 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/MetricNames.java
@@ -1,6 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.http.server;
+import ai.vespa.metrics.ContainerMetrics;
+
/**
* Place to store the metric names so where the metrics are logged can be found
* more easily in an IDE.
@@ -8,24 +10,21 @@ package com.yahoo.vespa.http.server;
* @author steinar
*/
public final class MetricNames {
-
- private static final String PREFIX = "httpapi_";
-
- public static final String NUM_OPERATIONS = PREFIX + "num_operations";
- public static final String NUM_PUTS = PREFIX + "num_puts";
- public static final String NUM_REMOVES = PREFIX + "num_removes";
- public static final String NUM_UPDATES = PREFIX + "num_updates";
- public static final String OPERATIONS_PER_SEC = PREFIX + "ops_per_sec";
- public static final String LATENCY = PREFIX + "latency";
- public static final String FAILED = PREFIX + "failed";
- public static final String CONDITION_NOT_MET = PREFIX + "condition_not_met";
- public static final String NOT_FOUND = PREFIX + "not_found";
- public static final String PARSE_ERROR = PREFIX + "parse_error";
- public static final String SUCCEEDED = PREFIX + "succeeded";
- public static final String PENDING = PREFIX + "pending";
- public static final String FAILED_UNKNOWN = FAILED + "_unknown";
- public static final String FAILED_TIMEOUT = FAILED + "_timeout";
- public static final String FAILED_INSUFFICIENT_STORAGE = FAILED + "_insufficient_storage";
+ public static final String NUM_OPERATIONS = ContainerMetrics.HTTPAPI_NUM_OPERATIONS.baseName();
+ public static final String NUM_PUTS = ContainerMetrics.HTTPAPI_NUM_PUTS.baseName();
+ public static final String NUM_REMOVES = ContainerMetrics.HTTPAPI_NUM_REMOVES.baseName();
+ public static final String NUM_UPDATES = ContainerMetrics.HTTPAPI_NUM_UPDATES.baseName();
+ public static final String OPERATIONS_PER_SEC = ContainerMetrics.HTTPAPI_OPS_PER_SEC.baseName();
+ public static final String LATENCY = ContainerMetrics.HTTPAPI_LATENCY.baseName();
+ public static final String FAILED = ContainerMetrics.HTTPAPI_FAILED.baseName();
+ public static final String CONDITION_NOT_MET = ContainerMetrics.HTTPAPI_CONDITION_NOT_MET.baseName();
+ public static final String NOT_FOUND = ContainerMetrics.HTTPAPI_NOT_FOUND.baseName();
+ public static final String PARSE_ERROR = ContainerMetrics.HTTPAPI_PARSE_ERROR.baseName();
+ public static final String SUCCEEDED = ContainerMetrics.HTTPAPI_SUCCEEDED.baseName();
+ public static final String PENDING = ContainerMetrics.HTTPAPI_PENDING.baseName();
+ public static final String FAILED_UNKNOWN = ContainerMetrics.HTTPAPI_FAILED_UNKNOWN.baseName();
+ public static final String FAILED_TIMEOUT = ContainerMetrics.HTTPAPI_FAILED_TIMEOUT.baseName();
+ public static final String FAILED_INSUFFICIENT_STORAGE = ContainerMetrics.HTTPAPI_FAILED_INSUFFICIENT_STORAGE.baseName();
private MetricNames() {
}