Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Siddhant Deshmukh <deshsid@amazon.com>
  • Loading branch information
deshsidd committed Jul 18, 2024
1 parent f29f530 commit 2486d24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static SearchQueryCategorizer getInstance(MetricsRegistry metricsRegistry
}

/**
* Consume records and increment counters for the records including latency, cpu and memory histograms.
* Consume records and increment categorization counters and histograms for the records including latency, cpu and memory.
* @param records records to consume
*/
public void consumeRecords(List<SearchQueryRecord> records) {
Expand All @@ -76,9 +76,9 @@ public void consumeRecords(List<SearchQueryRecord> records) {
}

/**
* Increment categorizations counters for the given source search query and
* Increment categorizations counters for the given search query record and
* also increment latency, cpu and memory related histograms.
* @param record search query source
* @param record search query record
*/
public void categorize(SearchQueryRecord record) {
SearchSourceBuilder source = (SearchSourceBuilder) record.getAttributes().get(Attribute.SOURCE);
Expand Down Expand Up @@ -139,6 +139,8 @@ public SearchQueryCounters getSearchQueryCounters() {
* Reset the search query categorizer and its counters
*/
public void reset() {
instance = null;
synchronized (SearchQueryCategorizer.class) {
instance = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ public final class SearchQueryCategorizerTests extends OpenSearchTestCase {

private SearchQueryCategorizer searchQueryCategorizer;

private Map<MetricType, Number> measurements;

@Before
public void setup() {
SearchQueryCategorizer.getInstance(mock(MetricsRegistry.class)).reset();
metricsRegistry = mock(MetricsRegistry.class);
when(metricsRegistry.createCounter(any(String.class), any(String.class), any(String.class))).thenAnswer(
invocation -> mock(Counter.class)
Expand Down

0 comments on commit 2486d24

Please sign in to comment.