Skip to content

Commit 8beceda

Browse files
author
Lei Lu
authored
[router][client] Unused router metrics cleanup (linkedin#1882)
This is part of an effort to reduce metric usage across Venice services and this PR is targeting venice router metrics. For `SINGLE_GET` request type, this PR removes the following metrics: "--key_num" "--fanout_request_count" "--multiget_fallback" "--unavailable_replica_streaming_request" For `MULTIGET_STREAMING`: "--multiget_streaming_read_quota_usage_kps" "--multiget_streaming_request_usage" "--multiget_streaming_multiget_fallback" For `COMPUTE_STREAMING`: "--compute_streaming_request_usage"
1 parent 5cfaed8 commit 8beceda

3 files changed

Lines changed: 84 additions & 14 deletions

File tree

internal/venice-client-common/src/main/java/com/linkedin/venice/read/RequestType.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,16 @@ public VeniceMetricsDimensions getDimensionName() {
3131
public String getDimensionValue() {
3232
return name().toLowerCase();
3333
}
34+
35+
public static boolean isSingleGet(RequestType requestType) {
36+
return requestType == SINGLE_GET;
37+
}
38+
39+
public static boolean isCompute(RequestType requestType) {
40+
return requestType == COMPUTE;
41+
}
42+
43+
public static boolean isStreaming(RequestType requestType) {
44+
return requestType == MULTI_GET_STREAMING || requestType == COMPUTE_STREAMING;
45+
}
3446
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.linkedin.venice.read;
2+
3+
import static org.testng.Assert.assertFalse;
4+
import static org.testng.Assert.assertTrue;
5+
6+
import org.testng.annotations.Test;
7+
8+
9+
public class RequestTypeTest {
10+
@Test
11+
public void testBooleanFuncInRequestType() {
12+
// Test the boolean functions in RequestType enum.
13+
for (RequestType requestType: RequestType.values()) {
14+
if (requestType == RequestType.SINGLE_GET) {
15+
assertTrue(RequestType.isSingleGet(requestType), "SINGLE_GET should be recognized as a single GET");
16+
} else {
17+
assertFalse(RequestType.isSingleGet(requestType), requestType + " should not be recognized as a single GET");
18+
}
19+
20+
if (requestType == RequestType.COMPUTE) {
21+
assertTrue(RequestType.isCompute(requestType), "COMPUTE should be recognized as a compute request");
22+
} else {
23+
assertFalse(RequestType.isCompute(requestType), requestType + " should not be recognized as a compute request");
24+
}
25+
26+
if (requestType == RequestType.MULTI_GET_STREAMING || requestType == RequestType.COMPUTE_STREAMING) {
27+
assertTrue(RequestType.isStreaming(requestType), requestType + " should be recognized as a streaming request");
28+
} else {
29+
assertFalse(
30+
RequestType.isStreaming(requestType),
31+
requestType + " should not be recognized as a streaming request");
32+
}
33+
}
34+
}
35+
}

services/venice-router/src/main/java/com/linkedin/venice/router/stats/RouterHttpRequestStats.java

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ public RouterHttpRequestStats(
185185
registerSensor(new TehutiUtils.SimpleRatioStat(healthyRequestRate, requestRate, "healthy_request_ratio"));
186186
tardyRequestRatioSensor =
187187
registerSensor(new TehutiUtils.SimpleRatioStat(tardyRequestRate, requestRate, "tardy_request_ratio"));
188-
keyNumSensor = registerSensor("key_num", new Avg(), new Max(0));
188+
189+
keyNumSensor = RequestType.isSingleGet(requestType) ? null : registerSensor("key_num", new Avg(), new Max(0));
190+
189191
badRequestKeyCountSensor = registerSensor("bad_request_key_count", new OccurrenceRate(), new Avg(), new Max());
190192

191193
healthyRequestMetric = MetricEntityStateThreeEnums.create(
@@ -374,9 +376,12 @@ public RouterHttpRequestStats(
374376
errorRetryAttemptTriggeredByPendingRequestCheckSensor =
375377
registerSensor("error_retry_attempt_triggered_by_pending_request_check", new OccurrenceRate());
376378

377-
unavailableReplicaStreamingRequestSensor = registerSensor("unavailable_replica_streaming_request", new Count());
379+
unavailableReplicaStreamingRequestSensor = !RequestType.isStreaming(requestType)
380+
? null
381+
: registerSensor("unavailable_replica_streaming_request", new Count());
378382
requestThrottledByRouterCapacitySensor = registerSensor("request_throttled_by_router_capacity", new Count());
379-
fanoutRequestCountSensor = registerSensor("fanout_request_count", new Avg(), new Max(0));
383+
fanoutRequestCountSensor =
384+
RequestType.isSingleGet(requestType) ? null : registerSensor("fanout_request_count", new Avg(), new Max(0));
380385

381386
routerResponseWaitingTimeSensor = registerSensor(
382387
"response_waiting_time",
@@ -420,22 +425,28 @@ public RouterHttpRequestStats(
420425
/**
421426
* request_usage.Total is incoming KPS while request_usage.OccurrenceRate is QPS
422427
*/
423-
requestUsageSensor = registerSensor("request_usage", new Total(), new OccurrenceRate());
428+
requestUsageSensor = RequestType.isSingleGet(requestType)
429+
? registerSensor("request_usage", new Total(), new OccurrenceRate())
430+
: null;
424431

425432
/**
426433
* A count version of this sensor is needed, as an internal system depends on the sensor to be
427434
* of type Count to measure QPS.
428435
*/
429-
requestCallCountSensor = registerSensor("request_call_count", new Count());
436+
requestCallCountSensor =
437+
RequestType.isSingleGet(requestType) ? registerSensor("request_call_count", new Count()) : null;
430438

431-
multiGetFallbackSensor = registerSensor("multiget_fallback", new Total(), new OccurrenceRate());
439+
multiGetFallbackSensor = !RequestType.isCompute(requestType)
440+
? null
441+
: registerSensor("multiget_fallback", new Total(), new OccurrenceRate());
432442

433443
requestParsingLatencySensor = registerSensor("request_parse_latency", new Avg());
434444
requestRoutingLatencySensor = registerSensor("request_route_latency", new Avg());
435445

436446
unAvailableRequestSensor = registerSensor("unavailable_request", new Count());
437447

438-
readQuotaUsageSensor = registerSensor("read_quota_usage_kps", new Total());
448+
readQuotaUsageSensor =
449+
RequestType.isSingleGet(requestType) ? registerSensor("read_quota_usage_kps", new Total()) : null;
439450

440451
inFlightRequestSensor = registerSensor("in_flight_request_count", new Min(), new Max(0), new Avg());
441452

@@ -519,15 +530,19 @@ private void recordRequestMetrics(
519530
}
520531

521532
public void recordUnavailableReplicaStreamingRequest() {
522-
unavailableReplicaStreamingRequestSensor.record();
533+
if (unavailableReplicaStreamingRequestSensor != null) {
534+
unavailableReplicaStreamingRequestSensor.record();
535+
}
523536
}
524537

525538
/**
526539
* Record read quota usage based on healthy KPS.
527540
* @param quotaUsage
528541
*/
529542
public void recordReadQuotaUsage(int quotaUsage) {
530-
readQuotaUsageSensor.record(quotaUsage);
543+
if (readQuotaUsageSensor != null) {
544+
readQuotaUsageSensor.record(quotaUsage);
545+
}
531546
}
532547

533548
public void recordTardyRequest(double latency, HttpResponseStatus responseStatus, int keyNum) {
@@ -602,7 +617,7 @@ public void recordRequestThrottledByRouterCapacity() {
602617
}
603618

604619
public void recordFanoutRequestCount(int count) {
605-
if (!getRequestType().equals(RequestType.SINGLE_GET)) {
620+
if (fanoutRequestCountSensor != null) {
606621
fanoutRequestCountSensor.record(count);
607622
}
608623
}
@@ -644,7 +659,9 @@ public void recordFindUnhealthyHostRequest() {
644659
}
645660

646661
public void recordIncomingKeyCountMetric(int keyNum) {
647-
keyNumSensor.record(keyNum);
662+
if (keyNumSensor != null) {
663+
keyNumSensor.record(keyNum);
664+
}
648665
}
649666

650667
public void recordIncomingBadRequestKeyCountMetric(HttpResponseStatus responseStatus, int keyNum) {
@@ -657,12 +674,18 @@ public void recordIncomingBadRequestKeyCountMetric(HttpResponseStatus responseSt
657674
}
658675

659676
public void recordRequestUsage(int usage) {
660-
requestUsageSensor.record(usage);
661-
requestCallCountSensor.record();
677+
if (requestUsageSensor != null) {
678+
requestUsageSensor.record(usage);
679+
}
680+
if (requestCallCountSensor != null) {
681+
requestCallCountSensor.record();
682+
}
662683
}
663684

664685
public void recordMultiGetFallback(int keyCount) {
665-
multiGetFallbackSensor.record(keyCount);
686+
if (multiGetFallbackSensor != null) {
687+
multiGetFallbackSensor.record(keyCount);
688+
}
666689
}
667690

668691
public void recordRequestParsingLatency(double latency) {

0 commit comments

Comments
 (0)