-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[router] remove store level metrics for non-streaming multiget #1306
Open
xunyin8
wants to merge
1
commit into
linkedin:main
Choose a base branch
from
xunyin8:RemoveNonStreamingMetrics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,14 @@ | |
import com.linkedin.venice.utils.concurrent.VeniceConcurrentHashMap; | ||
import io.tehuti.metrics.MetricsRepository; | ||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
import java.util.function.Function; | ||
|
||
|
||
public class AggRouterHttpRequestStats extends AbstractVeniceAggStoreStats<RouterHttpRequestStats> { | ||
private final Map<String, ScatterGatherStats> scatterGatherStatsMap = new VeniceConcurrentHashMap<>(); | ||
private final boolean isStoreStatsEnabled; | ||
private final ScatterGatherStats totalScatterGatherStats; | ||
|
||
public AggRouterHttpRequestStats( | ||
MetricsRepository metricsRepository, | ||
|
@@ -29,14 +32,18 @@ public AggRouterHttpRequestStats( | |
ReadOnlyStoreRepository metadataRepository, | ||
boolean isUnregisterMetricForDeletedStoreEnabled) { | ||
super(metricsRepository, metadataRepository, isUnregisterMetricForDeletedStoreEnabled); | ||
// Disable store level non-streaming multi get stats reporting because it's no longer used in clients. We still | ||
// report to the total stats for visibility of potential old clients. | ||
isStoreStatsEnabled = !RequestType.MULTI_GET.equals(requestType); | ||
totalScatterGatherStats = new AggScatterGatherStats(); | ||
/** | ||
* Use a setter function to bypass the restriction that the supertype constructor could not | ||
* touch member fields of current object. | ||
*/ | ||
setStatsSupplier((metricsRepo, storeName) -> { | ||
ScatterGatherStats stats; | ||
if (storeName.equals(AbstractVeniceAggStats.STORE_NAME_FOR_TOTAL_STAT)) { | ||
stats = new AggScatterGatherStats(); | ||
stats = totalScatterGatherStats; | ||
} else { | ||
stats = scatterGatherStatsMap.computeIfAbsent(storeName, k -> new ScatterGatherStats()); | ||
} | ||
|
@@ -46,35 +53,45 @@ public AggRouterHttpRequestStats( | |
} | ||
|
||
public ScatterGatherStats getScatterGatherStatsForStore(String storeName) { | ||
return scatterGatherStatsMap.computeIfAbsent(storeName, k -> new ScatterGatherStats()); | ||
if (isStoreStatsEnabled) { | ||
return scatterGatherStatsMap.computeIfAbsent(storeName, k -> new ScatterGatherStats()); | ||
} else { | ||
return totalScatterGatherStats; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this result in dual recording of the total stats? |
||
} | ||
} | ||
|
||
private void recordStoreStats(String storeName, Consumer<RouterHttpRequestStats> statsConsumer) { | ||
if (isStoreStatsEnabled) { | ||
statsConsumer.accept(getStoreStats(storeName)); | ||
} | ||
} | ||
|
||
public void recordRequest(String storeName) { | ||
totalStats.recordRequest(); | ||
getStoreStats(storeName).recordRequest(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordRequest); | ||
} | ||
|
||
public void recordHealthyRequest(String storeName, double latency) { | ||
totalStats.recordHealthyRequest(latency); | ||
getStoreStats(storeName).recordHealthyRequest(latency); | ||
recordStoreStats(storeName, stats -> stats.recordHealthyRequest(latency)); | ||
} | ||
|
||
public void recordUnhealthyRequest(String storeName) { | ||
totalStats.recordUnhealthyRequest(); | ||
if (storeName != null) { | ||
getStoreStats(storeName).recordUnhealthyRequest(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordUnhealthyRequest); | ||
} | ||
} | ||
|
||
public void recordUnavailableReplicaStreamingRequest(String storeName) { | ||
totalStats.recordUnavailableReplicaStreamingRequest(); | ||
getStoreStats(storeName).recordUnavailableReplicaStreamingRequest(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordUnavailableReplicaStreamingRequest); | ||
} | ||
|
||
public void recordUnhealthyRequest(String storeName, double latency) { | ||
totalStats.recordUnhealthyRequest(latency); | ||
if (storeName != null) { | ||
getStoreStats(storeName).recordUnhealthyRequest(latency); | ||
recordStoreStats(storeName, stats -> stats.recordUnhealthyRequest(latency)); | ||
} | ||
} | ||
|
||
|
@@ -86,12 +103,12 @@ public void recordUnhealthyRequest(String storeName, double latency) { | |
*/ | ||
public void recordReadQuotaUsage(String storeName, int quotaUsage) { | ||
totalStats.recordReadQuotaUsage(quotaUsage); | ||
getStoreStats(storeName).recordReadQuotaUsage(quotaUsage); | ||
recordStoreStats(storeName, stats -> stats.recordReadQuotaUsage(quotaUsage)); | ||
} | ||
|
||
public void recordTardyRequest(String storeName, double latency) { | ||
totalStats.recordTardyRequest(latency); | ||
getStoreStats(storeName).recordTardyRequest(latency); | ||
recordStoreStats(storeName, stats -> stats.recordTardyRequest(latency)); | ||
} | ||
|
||
/** | ||
|
@@ -103,79 +120,79 @@ public void recordTardyRequest(String storeName, double latency) { | |
*/ | ||
public void recordThrottledRequest(String storeName) { | ||
totalStats.recordThrottledRequest(); | ||
getStoreStats(storeName).recordThrottledRequest(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordThrottledRequest); | ||
} | ||
|
||
public void recordThrottledRequest(String storeName, double latency) { | ||
totalStats.recordThrottledRequest(latency); | ||
getStoreStats(storeName).recordThrottledRequest(latency); | ||
recordStoreStats(storeName, stats -> stats.recordThrottledRequest(latency)); | ||
} | ||
|
||
public void recordBadRequest(String storeName) { | ||
totalStats.recordBadRequest(); | ||
if (storeName != null) { | ||
getStoreStats(storeName).recordBadRequest(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordBadRequest); | ||
} | ||
} | ||
|
||
public void recordBadRequestKeyCount(String storeName, int keyCount) { | ||
totalStats.recordBadRequestKeyCount(keyCount); | ||
if (storeName != null) { | ||
getStoreStats(storeName).recordBadRequestKeyCount(keyCount); | ||
recordStoreStats(storeName, stats -> stats.recordBadRequestKeyCount(keyCount)); | ||
} | ||
} | ||
|
||
public void recordRequestThrottledByRouterCapacity(String storeName) { | ||
totalStats.recordRequestThrottledByRouterCapacity(); | ||
if (storeName != null) { | ||
getStoreStats(storeName).recordRequestThrottledByRouterCapacity(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordRequestThrottledByRouterCapacity); | ||
} | ||
} | ||
|
||
public void recordErrorRetryCount(String storeName) { | ||
totalStats.recordErrorRetryCount(); | ||
if (storeName != null) { | ||
getStoreStats(storeName).recordErrorRetryCount(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordErrorRetryCount); | ||
} | ||
} | ||
|
||
public void recordFanoutRequestCount(String storeName, int count) { | ||
totalStats.recordFanoutRequestCount(count); | ||
getStoreStats(storeName).recordFanoutRequestCount(count); | ||
recordStoreStats(storeName, stats -> stats.recordFanoutRequestCount(count)); | ||
} | ||
|
||
public void recordLatency(String storeName, double latency) { | ||
totalStats.recordLatency(latency); | ||
getStoreStats(storeName).recordLatency(latency); | ||
recordStoreStats(storeName, stats -> stats.recordLatency(latency)); | ||
} | ||
|
||
public void recordResponseWaitingTime(String storeName, double waitingTime) { | ||
totalStats.recordResponseWaitingTime(waitingTime); | ||
getStoreStats(storeName).recordResponseWaitingTime(waitingTime); | ||
recordStoreStats(storeName, stats -> stats.recordResponseWaitingTime(waitingTime)); | ||
} | ||
|
||
public void recordRequestSize(String storeName, double keySize) { | ||
totalStats.recordRequestSize(keySize); | ||
getStoreStats(storeName).recordRequestSize(keySize); | ||
recordStoreStats(storeName, stats -> stats.recordRequestSize(keySize)); | ||
} | ||
|
||
public void recordCompressedResponseSize(String storeName, double compressedResponseSize) { | ||
totalStats.recordCompressedResponseSize(compressedResponseSize); | ||
getStoreStats(storeName).recordCompressedResponseSize(compressedResponseSize); | ||
recordStoreStats(storeName, stats -> stats.recordCompressedResponseSize(compressedResponseSize)); | ||
} | ||
|
||
public void recordResponseSize(String storeName, double valueSize) { | ||
totalStats.recordResponseSize(valueSize); | ||
getStoreStats(storeName).recordResponseSize(valueSize); | ||
recordStoreStats(storeName, stats -> stats.recordResponseSize(valueSize)); | ||
} | ||
|
||
public void recordDecompressionTime(String storeName, double decompressionTime) { | ||
totalStats.recordDecompressionTime(decompressionTime); | ||
getStoreStats(storeName).recordDecompressionTime(decompressionTime); | ||
recordStoreStats(storeName, stats -> stats.recordDecompressionTime(decompressionTime)); | ||
} | ||
|
||
public void recordQuota(String storeName, double quota) { | ||
getStoreStats(storeName).recordQuota(quota); | ||
recordStoreStats(storeName, stats -> stats.recordQuota(quota)); | ||
} | ||
|
||
public void recordTotalQuota(double totalQuota) { | ||
|
@@ -184,17 +201,17 @@ public void recordTotalQuota(double totalQuota) { | |
|
||
public void recordFindUnhealthyHostRequest(String storeName) { | ||
totalStats.recordFindUnhealthyHostRequest(); | ||
getStoreStats(storeName).recordFindUnhealthyHostRequest(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordFindUnhealthyHostRequest); | ||
} | ||
|
||
public void recordResponse(String storeName) { | ||
totalStats.recordResponse(); | ||
getStoreStats(storeName).recordResponse(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordResponse); | ||
} | ||
|
||
public void recordMetaStoreShadowRead(String storeName) { | ||
totalStats.recordMetaStoreShadowRead(); | ||
getStoreStats(storeName).recordMetaStoreShadowRead(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordMetaStoreShadowRead); | ||
} | ||
|
||
private class AggScatterGatherStats extends ScatterGatherStats { | ||
|
@@ -234,47 +251,47 @@ public long getTotalRetriesError() { | |
|
||
public void recordKeyNum(String storeName, int keyNum) { | ||
totalStats.recordKeyNum(keyNum); | ||
getStoreStats(storeName).recordKeyNum(keyNum); | ||
recordStoreStats(storeName, stats -> stats.recordKeyNum(keyNum)); | ||
} | ||
|
||
public void recordRequestUsage(String storeName, int usage) { | ||
totalStats.recordRequestUsage(usage); | ||
getStoreStats(storeName).recordRequestUsage(usage); | ||
recordStoreStats(storeName, stats -> stats.recordRequestUsage(usage)); | ||
} | ||
|
||
public void recordMultiGetFallback(String storeName, int keyCount) { | ||
totalStats.recordMultiGetFallback(keyCount); | ||
getStoreStats(storeName).recordMultiGetFallback(keyCount); | ||
recordStoreStats(storeName, stats -> stats.recordMultiGetFallback(keyCount)); | ||
} | ||
|
||
public void recordRequestParsingLatency(String storeName, double latency) { | ||
totalStats.recordRequestParsingLatency(latency); | ||
getStoreStats(storeName).recordRequestParsingLatency(latency); | ||
recordStoreStats(storeName, stats -> stats.recordRequestParsingLatency(latency)); | ||
} | ||
|
||
public void recordRequestRoutingLatency(String storeName, double latency) { | ||
totalStats.recordRequestRoutingLatency(latency); | ||
getStoreStats(storeName).recordRequestRoutingLatency(latency); | ||
recordStoreStats(storeName, stats -> stats.recordRequestRoutingLatency(latency)); | ||
} | ||
|
||
public void recordUnavailableRequest(String storeName) { | ||
totalStats.recordUnavailableRequest(); | ||
getStoreStats(storeName).recordUnavailableRequest(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordUnavailableRequest); | ||
} | ||
|
||
public void recordDelayConstraintAbortedRetryRequest(String storeName) { | ||
totalStats.recordDelayConstraintAbortedRetryRequest(); | ||
getStoreStats(storeName).recordDelayConstraintAbortedRetryRequest(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordDelayConstraintAbortedRetryRequest); | ||
} | ||
|
||
public void recordSlowRouteAbortedRetryRequest(String storeName) { | ||
totalStats.recordSlowRouteAbortedRetryRequest(); | ||
getStoreStats(storeName).recordSlowRouteAbortedRetryRequest(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordSlowRouteAbortedRetryRequest); | ||
} | ||
|
||
public void recordRetryRouteLimitAbortedRetryRequest(String storeName) { | ||
totalStats.recordRetryRouteLimitAbortedRetryRequest(); | ||
getStoreStats(storeName).recordRetryRouteLimitAbortedRetryRequest(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordRetryRouteLimitAbortedRetryRequest); | ||
} | ||
|
||
public void recordKeySize(String storeName, long keySize) { | ||
|
@@ -283,26 +300,26 @@ public void recordKeySize(String storeName, long keySize) { | |
|
||
public void recordAllowedRetryRequest(String storeName) { | ||
totalStats.recordAllowedRetryRequest(); | ||
getStoreStats(storeName).recordAllowedRetryRequest(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordAllowedRetryRequest); | ||
} | ||
|
||
public void recordDisallowedRetryRequest(String storeName) { | ||
totalStats.recordDisallowedRetryRequest(); | ||
getStoreStats(storeName).recordDisallowedRetryRequest(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordDisallowedRetryRequest); | ||
} | ||
|
||
public void recordNoAvailableReplicaAbortedRetryRequest(String storeName) { | ||
totalStats.recordNoAvailableReplicaAbortedRetryRequest(); | ||
getStoreStats(storeName).recordRetryRouteLimitAbortedRetryRequest(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordNoAvailableReplicaAbortedRetryRequest); | ||
} | ||
|
||
public void recordErrorRetryAttemptTriggeredByPendingRequestCheck(String storeName) { | ||
totalStats.recordErrorRetryAttemptTriggeredByPendingRequestCheck(); | ||
getStoreStats(storeName).recordErrorRetryAttemptTriggeredByPendingRequestCheck(); | ||
recordStoreStats(storeName, RouterHttpRequestStats::recordErrorRetryAttemptTriggeredByPendingRequestCheck); | ||
} | ||
|
||
public void recordRetryDelay(String storeName, double delay) { | ||
totalStats.recordRetryDelay(delay); | ||
getStoreStats(storeName).recordRetryDelay(delay); | ||
recordStoreStats(storeName, stats -> stats.recordRetryDelay(delay)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just remove MULTI_GET? Do we have any use cases for this?