-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Can match phase coordinator duration APM metric #136828
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
Changes from 12 commits
72eaef0
5fea595
cb58c0e
97bfd37
f31181e
9ef90b0
76844ec
07a8a3e
ca3fd60
c4aa227
3e07ffa
e295593
cdffc5b
85ddf1d
3d8dcd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 136828 | ||
| summary: Can match phase coordinator duration APM metric | ||
| area: Search | ||
| type: enhancement | ||
| issues: [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ public class SearchPhaseCoordinatorAPMMetricsTests extends ESSingleNodeTestCase | |
| private static final String indexName = "test_coordinator_search_phase_metrics"; | ||
| private final int num_primaries = randomIntBetween(2, 7); | ||
|
|
||
| private static final String CAN_MATCH_SEARCH_PHASE_METRIC = "es.search_response.took_durations.can_match.histogram"; | ||
| private static final String DFS_QUERY_SEARCH_PHASE_METRIC = "es.search_response.took_durations.dfs_query.histogram"; | ||
| private static final String DFS_SEARCH_PHASE_METRIC = "es.search_response.took_durations.dfs.histogram"; | ||
| private static final String FETCH_SEARCH_PHASE_METRIC = "es.search_response.took_durations.fetch.histogram"; | ||
|
|
@@ -82,19 +83,45 @@ public void testSearchQueryThenFetch() { | |
| client().prepareSearch(indexName).setSearchType(SearchType.QUERY_THEN_FETCH).setQuery(simpleQueryStringQuery("doc1")), | ||
| "1" | ||
| ); | ||
| assertMeasurements(List.of(QUERY_SEARCH_PHASE_METRIC, FETCH_SEARCH_PHASE_METRIC)); | ||
| assertMeasurements(List.of(QUERY_SEARCH_PHASE_METRIC, FETCH_SEARCH_PHASE_METRIC), 1); | ||
| assertNotMeasured( | ||
| List.of(CAN_MATCH_SEARCH_PHASE_METRIC, DFS_SEARCH_PHASE_METRIC, DFS_QUERY_SEARCH_PHASE_METRIC, OPEN_PIT_SEARCH_PHASE_METRIC) | ||
| ); | ||
| } | ||
|
|
||
| public void testDfsSearch() { | ||
| assertSearchHitsWithoutFailures( | ||
| client().prepareSearch(indexName).setSearchType(SearchType.DFS_QUERY_THEN_FETCH).setQuery(simpleQueryStringQuery("doc1")), | ||
| "1" | ||
| ); | ||
| assertMeasurements(List.of(DFS_SEARCH_PHASE_METRIC, DFS_QUERY_SEARCH_PHASE_METRIC, FETCH_SEARCH_PHASE_METRIC)); | ||
| assertMeasurements(List.of(DFS_SEARCH_PHASE_METRIC, DFS_QUERY_SEARCH_PHASE_METRIC, FETCH_SEARCH_PHASE_METRIC), 1); | ||
| assertNotMeasured(List.of(CAN_MATCH_SEARCH_PHASE_METRIC, QUERY_SEARCH_PHASE_METRIC, OPEN_PIT_SEARCH_PHASE_METRIC)); | ||
| } | ||
|
|
||
| public void testPointInTime() { | ||
| OpenPointInTimeRequest request = new OpenPointInTimeRequest(indexName).keepAlive(TimeValue.timeValueMinutes(10)); | ||
| request.indexFilter(simpleQueryStringQuery("doc1")); | ||
| OpenPointInTimeResponse response = client().execute(TransportOpenPointInTimeAction.TYPE, request).actionGet(); | ||
| BytesReference pointInTimeId = response.getPointInTimeId(); | ||
|
|
||
| try { | ||
| assertSearchHitsWithoutFailures( | ||
| client().prepareSearch() | ||
| .setPointInTime(new PointInTimeBuilder(pointInTimeId)) | ||
| .setSize(1) | ||
| .setQuery(simpleQueryStringQuery("doc1")), | ||
| "1" | ||
| ); | ||
| assertMeasurements(List.of(OPEN_PIT_SEARCH_PHASE_METRIC, QUERY_SEARCH_PHASE_METRIC, FETCH_SEARCH_PHASE_METRIC), 1); | ||
| assertNotMeasured(List.of(DFS_SEARCH_PHASE_METRIC, DFS_QUERY_SEARCH_PHASE_METRIC)); | ||
| } finally { | ||
| client().execute(TransportClosePointInTimeAction.TYPE, new ClosePointInTimeRequest(pointInTimeId)).actionGet(); | ||
| } | ||
| } | ||
|
|
||
| public void testPointInTimeWithPreFiltering() { | ||
| OpenPointInTimeRequest request = new OpenPointInTimeRequest(indexName).keepAlive(TimeValue.timeValueMinutes(10)); | ||
| request.indexFilter(simpleQueryStringQuery("doc1")); | ||
|
||
| OpenPointInTimeResponse response = client().execute(TransportOpenPointInTimeAction.TYPE, request).actionGet(); | ||
| BytesReference pointInTimeId = response.getPointInTimeId(); | ||
|
|
||
|
|
@@ -103,15 +130,34 @@ public void testPointInTime() { | |
| client().prepareSearch() | ||
| .setPointInTime(new PointInTimeBuilder(pointInTimeId)) | ||
| .setSize(1) | ||
| .setPreFilterShardSize(1) | ||
| .setQuery(simpleQueryStringQuery("doc1")), | ||
| "1" | ||
| ); | ||
| assertMeasurements(List.of(OPEN_PIT_SEARCH_PHASE_METRIC, QUERY_SEARCH_PHASE_METRIC, FETCH_SEARCH_PHASE_METRIC)); | ||
| assertMeasurements(List.of(OPEN_PIT_SEARCH_PHASE_METRIC, QUERY_SEARCH_PHASE_METRIC, FETCH_SEARCH_PHASE_METRIC), 1); | ||
| assertMeasurements( | ||
| List.of(CAN_MATCH_SEARCH_PHASE_METRIC), | ||
| 2 // one during open PIT, one during can-match phase of search | ||
| ); | ||
| assertNotMeasured(List.of(DFS_SEARCH_PHASE_METRIC, DFS_QUERY_SEARCH_PHASE_METRIC)); | ||
| } finally { | ||
| client().execute(TransportClosePointInTimeAction.TYPE, new ClosePointInTimeRequest(pointInTimeId)).actionGet(); | ||
| } | ||
| } | ||
|
|
||
| public void testCanMatchSearch() { | ||
chrisparrinello marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assertSearchHitsWithoutFailures( | ||
| client().prepareSearch(indexName) | ||
| .setSearchType(SearchType.QUERY_THEN_FETCH) | ||
| .setPreFilterShardSize(1) | ||
| .setQuery(simpleQueryStringQuery("doc1")), | ||
| "1" | ||
| ); | ||
|
|
||
| assertMeasurements(List.of(CAN_MATCH_SEARCH_PHASE_METRIC, FETCH_SEARCH_PHASE_METRIC, QUERY_SEARCH_PHASE_METRIC), 1); | ||
| assertNotMeasured(List.of(DFS_SEARCH_PHASE_METRIC, DFS_QUERY_SEARCH_PHASE_METRIC, OPEN_PIT_SEARCH_PHASE_METRIC)); | ||
| } | ||
|
|
||
| private void resetMeter() { | ||
| getTestTelemetryPlugin().resetMeter(); | ||
| } | ||
|
|
@@ -120,11 +166,18 @@ private TestTelemetryPlugin getTestTelemetryPlugin() { | |
| return getInstanceFromNode(PluginsService.class).filterPlugins(TestTelemetryPlugin.class).toList().get(0); | ||
| } | ||
|
|
||
| private void assertMeasurements(Collection<String> metricNames) { | ||
| private void assertNotMeasured(Collection<String> metricNames) { | ||
| for (var metricName : metricNames) { | ||
| List<Measurement> measurements = getTestTelemetryPlugin().getLongHistogramMeasurement(metricName); | ||
| assertThat(metricName, measurements, hasSize(0)); | ||
| } | ||
| } | ||
|
|
||
| private void assertMeasurements(Collection<String> metricNames, int numberOfMeasurements) { | ||
| for (var metricName : metricNames) { | ||
| List<Measurement> measurements = getTestTelemetryPlugin().getLongHistogramMeasurement(metricName); | ||
| assertThat(measurements, hasSize(1)); | ||
| assertThat(measurements.getFirst().getLong(), greaterThanOrEqualTo(0L)); | ||
| assertThat(metricName, measurements, hasSize(numberOfMeasurements)); | ||
| assertThat(metricName, measurements.getFirst().getLong(), greaterThanOrEqualTo(0L)); | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.