-
Notifications
You must be signed in to change notification settings - Fork 114
[server] Adding metric to capture key not found #2379
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
Open
ymuppala
wants to merge
3
commits into
linkedin:main
Choose a base branch
from
ymuppala:non_existent_keys
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
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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
This file contains hidden or 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
132 changes: 132 additions & 0 deletions
132
...ntegrationTest/java/com/linkedin/venice/storagenode/KeyNotFoundMetricIntegrationTest.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| package com.linkedin.venice.storagenode; | ||
|
|
||
| import com.linkedin.venice.client.store.AvroGenericStoreClient; | ||
| import com.linkedin.venice.client.store.ClientConfig; | ||
| import com.linkedin.venice.client.store.ClientFactory; | ||
| import com.linkedin.venice.controllerapi.UpdateStoreQueryParams; | ||
| import com.linkedin.venice.integration.utils.ServiceFactory; | ||
| import com.linkedin.venice.integration.utils.VeniceClusterCreateOptions; | ||
| import com.linkedin.venice.integration.utils.VeniceClusterWrapper; | ||
| import com.linkedin.venice.tehuti.MetricsUtils; | ||
| import com.linkedin.venice.utils.TestUtils; | ||
| import com.linkedin.venice.utils.Utils; | ||
| import java.util.AbstractMap; | ||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
| import java.util.concurrent.TimeUnit; | ||
| import java.util.stream.Stream; | ||
| import org.apache.avro.Schema; | ||
| import org.apache.avro.generic.GenericData; | ||
| import org.apache.avro.generic.GenericRecord; | ||
| import org.testng.Assert; | ||
| import org.testng.annotations.AfterClass; | ||
| import org.testng.annotations.BeforeClass; | ||
| import org.testng.annotations.Test; | ||
|
|
||
|
|
||
| public class KeyNotFoundMetricIntegrationTest { | ||
| private VeniceClusterWrapper veniceCluster; | ||
| private String storeName; | ||
| private AvroGenericStoreClient<String, GenericRecord> client; | ||
|
|
||
| @BeforeClass | ||
| public void setUp() { | ||
| veniceCluster = ServiceFactory.getVeniceCluster(new VeniceClusterCreateOptions.Builder().build()); | ||
| storeName = Utils.getUniqueString("test-store"); | ||
| String valueSchemaStr = "{" + " \"type\": \"record\"," + " \"name\": \"User\"," + " \"fields\": [" | ||
| + " {\"name\": \"name\", \"type\": \"string\"}" + " ]" + "}"; | ||
| veniceCluster.useControllerClient(controllerClient -> { | ||
| controllerClient.createNewStore(storeName, "owner", "\"string\"", valueSchemaStr); | ||
| controllerClient.updateStore(storeName, new UpdateStoreQueryParams().setReadComputationEnabled(true)); | ||
| }); | ||
|
|
||
| Schema valueSchema = Schema.parse(valueSchemaStr); | ||
| GenericRecord value1 = new GenericData.Record(valueSchema); | ||
| value1.put("name", "value1"); | ||
|
|
||
| veniceCluster.createVersion( | ||
| storeName, | ||
| "\"string\"", | ||
| valueSchemaStr, | ||
| Stream.of(new AbstractMap.SimpleEntry<>("key1", value1))); | ||
|
|
||
| client = ClientFactory.getAndStartGenericAvroClient( | ||
| ClientConfig.defaultGenericClientConfig(storeName).setVeniceURL(veniceCluster.getRandomRouterURL())); | ||
| } | ||
|
|
||
| @AfterClass | ||
| public void cleanUp() { | ||
| Utils.closeQuietlyWithErrorLogged(client); | ||
| Utils.closeQuietlyWithErrorLogged(veniceCluster); | ||
| } | ||
|
|
||
| @Test(singleThreaded = true) | ||
| public void testKeyNotFoundMetric() { | ||
| // Single Get - Key Found | ||
| try { | ||
| client.get("key1").get(); | ||
| } catch (Exception e) { | ||
| Assert.fail("Get failed", e); | ||
| } | ||
|
|
||
| // Single Get - Key Not Found | ||
| try { | ||
| client.get("key2").get(); | ||
| } catch (Exception e) { | ||
| Assert.fail("Get failed", e); | ||
| } | ||
|
|
||
| // Multi Get - 1 Key Found, 1 Key Not Found | ||
| Set<String> keys = new HashSet<>(); | ||
| keys.add("key1"); | ||
| keys.add("key3"); | ||
| try { | ||
| client.batchGet(keys).get(); | ||
| } catch (Exception e) { | ||
| Assert.fail("Batch Get failed", e); | ||
| } | ||
|
|
||
| // Compute - 1 Key Found, 1 Key Not Found | ||
| try { | ||
| client.compute().project("name").execute(keys).get(); | ||
| } catch (Exception e) { | ||
| Assert.fail("Compute failed", e); | ||
| } | ||
|
|
||
| String singleGetMetricName = "." + storeName + "--key_not_found.Rate"; | ||
| String multiGetMetricName = "." + storeName + "--multiget_key_not_found.Rate"; | ||
| String computeMetricName = "." + storeName + "--compute_key_not_found.Rate"; | ||
| String totalSingleGetMetricName = ".total--key_not_found.Rate"; | ||
| String totalMultiGetMetricName = ".total--multiget_key_not_found.Rate"; | ||
| String totalComputeMetricName = ".total--compute_key_not_found.Rate"; | ||
|
|
||
| TestUtils.waitForNonDeterministicAssertion(10, TimeUnit.SECONDS, () -> { | ||
| double singleGetNotFoundRate = MetricsUtils.getMax(singleGetMetricName, veniceCluster.getVeniceServers()); | ||
| double multiGetNotFoundRate = MetricsUtils.getMax(multiGetMetricName, veniceCluster.getVeniceServers()); | ||
| double computeNotFoundRate = MetricsUtils.getMax(computeMetricName, veniceCluster.getVeniceServers()); | ||
| double totalSingleGetNotFoundRate = | ||
| MetricsUtils.getMax(totalSingleGetMetricName, veniceCluster.getVeniceServers()); | ||
| double totalMultiGetNotFoundRate = MetricsUtils.getMax(totalMultiGetMetricName, veniceCluster.getVeniceServers()); | ||
| double totalComputeNotFoundRate = MetricsUtils.getMax(totalComputeMetricName, veniceCluster.getVeniceServers()); | ||
|
|
||
| Assert.assertTrue( | ||
| singleGetNotFoundRate > 0, | ||
| "Single Get key_not_found metric should be positive. Metric: " + singleGetMetricName); | ||
| Assert.assertTrue( | ||
| multiGetNotFoundRate > 0, | ||
| "Multi Get key_not_found metric should be positive. Metric: " + multiGetMetricName); | ||
| Assert.assertTrue( | ||
| computeNotFoundRate > 0, | ||
| "Compute key_not_found metric should be positive. Metric: " + computeMetricName); | ||
| Assert.assertTrue( | ||
| totalSingleGetNotFoundRate > 0, | ||
| "Total Single Get key_not_found metric should be positive. Metric: " + totalSingleGetMetricName); | ||
| Assert.assertTrue( | ||
| totalMultiGetNotFoundRate > 0, | ||
| "Total Multi Get key_not_found metric should be positive. Metric: " + totalMultiGetMetricName); | ||
| Assert.assertTrue( | ||
| totalComputeNotFoundRate > 0, | ||
| "Total Compute key_not_found metric should be positive. Metric: " + totalComputeMetricName); | ||
| }); | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.