Skip to content
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

SearchBackPressure Service Collector added #483

Merged

Conversation

CoderJeffrey
Copy link
Contributor

@CoderJeffrey CoderJeffrey commented Jun 19, 2023

Signed-off-by: Jeffrey Liu [email protected]

Is your feature request related to a problem? Please provide an existing Issue # , or describe.
Add the functionality to gather the SearchBackPressure Service.

Describe the solution you are proposing
Add SearchBackPressureStatsCollector.java to collect SearchBackPressure related metrics, and added Unit Testing for SearchBackPressureStatsCollector.java.

Describe alternatives you've considered
N/A

Additional context

  1. Changes in licenses/ are auto-created after running ./build gradlew

  2. In order to access the Constants field in this collector, another pull & request for performance-analyzer-commons package has been made.

    Example:
    @JsonProperty(SearchBackPressureStatsValue.Constants.SEARCHBP_NODEID) public String getSearchBackPressureStats_NodeId() { return this.nodeId; }

    Parallel Pull & Request link: SearchbackpressureStatsCollector Constants Added performance-analyzer-commons#33

    Approving this pull & request will be needed in order for the collector to access the Performance-Analyzer-Commons Constants fields. Or else, error would occur.

  3. Can verify the extracted search_back_pressure metrics in /dev/shm/performanceanalyzer directory, open any log file, and search for "search_back_pressure"

Check List

  • New functionality includes testing.
  • All tests pass
  • New functionality has been documented.
  • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@codecov
Copy link

codecov bot commented Jun 19, 2023

Codecov Report

Merging #483 (59a78bc) into main (5428a52) will increase coverage by 0.18%.
The diff coverage is 75.92%.

❗ Current head 59a78bc differs from pull request most recent head 1a0b4ed. Consider uploading reports for the commit 1a0b4ed to get more accurate results

@@             Coverage Diff              @@
##               main     #483      +/-   ##
============================================
+ Coverage     73.67%   73.85%   +0.18%     
- Complexity      375      381       +6     
============================================
  Files            44       45       +1     
  Lines          2477     2693     +216     
  Branches        172      172              
============================================
+ Hits           1825     1989     +164     
- Misses          544      596      +52     
  Partials        108      108              
Impacted Files Coverage Δ
...r/collectors/SearchBackPressureStatsCollector.java 75.70% <75.70%> (ø)
...performanceanalyzer/PerformanceAnalyzerPlugin.java 77.14% <100.00%> (+0.21%) ⬆️
...org/opensearch/performanceanalyzer/util/Utils.java 92.50% <100.00%> (+0.19%) ⬆️

@CoderJeffrey
Copy link
Contributor Author

CoderJeffrey commented Jun 19, 2023

In order to access the Constants field in this collector, another pull & request for performance-analyzer-commons package has been made.

Example:
@JsonProperty(SearchBackPressureStatsValue.Constants.SEARCHBP_NODEID) public String getSearchBackPressureStats_NodeId() { return this.nodeId; }

Parallel Pull & Request link: opensearch-project/performance-analyzer-commons#33
Approving this pull & request will be needed in order for the collector to access the commons constant fields. Or else, error would occur.

@getsaurabh02
Copy link
Member

Can we cleanup the bunch of jars which got along with the commit making the file changes as 37?

private SearchShardTaskStats searchShardTaskStats;
private SearchTaskStats searchTaskStats;

// private double searchBackPressureStatsTest;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this searchBackPressureStatsTest for testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// private double searchBackPressureStatsTest; is not needed for the collector.
thank you so much for pointing out, just removed this piece of code (comment).

this.searchbp_task_stats_cancellationCount = searchTaskStats.getCancellationCount();
this.searchbp_task_stats_limitReachedCount = searchTaskStats.getLimitReachedCount();
this.searchbp_task_stats_resource_heap_usage_cancellationCount =
searchTaskStats
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably rewrite this part of code to make it more readable, for example, using some temp variables to replace

searchTaskStats
                            .getResourceUsageTrackerStats()
                            .get(HEAP_USAGE_TRACKER_FIELD_NAME)

searchTaskStats
                            .getResourceUsageTrackerStats()
                            .get(CPU_USAGE_TRACKER_FIELD_NAME)

 searchTaskStats
                            .getResourceUsageTrackerStats()
                            .get(ELAPSED_TIME_USAGE_TRACKER_FIELD_NAME)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searchTaskStats
                            .getResourceUsageTrackerStats()
                            .get(HEAP_USAGE_TRACKER_FIELD_NAME)

Has now been simplified to
task_heap_stats

Similar simplification applies to other variables.

import org.powermock.modules.junit4.PowerMockRunner;

@RunWith(PowerMockRunner.class)
public class SearchBackPressureStatsCollectorTests {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the valid cases, we can add more tests for some invalid scenarios. For example, to test if an exception is correctly thrown under certain conditions.

Copy link
Contributor Author

@CoderJeffrey CoderJeffrey Jun 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to check for the exception for collectMetrics(), it is required to control the behavior of ObjectMapper, but since it is a private static field, and all exceptions are caught inside the collectMetrics() itself. Is it acceptable to only test for valid fields for now? i also check with other collect tests like ClusterManagerServiceEventMetricsTests.java, the additional exception testings are also omitted.

@CoderJeffrey
Copy link
Contributor Author

Can we cleanup the bunch of jars which got along with the commit making the file changes as 37?

Just cleaned up all jars.

ansjcy
ansjcy previously approved these changes Jun 22, 2023
Copy link
Member

@ansjcy ansjcy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

getsaurabh02
getsaurabh02 previously approved these changes Jun 23, 2023
import org.opensearch.search.backpressure.SearchBackpressureService;
import org.opensearch.search.backpressure.stats.SearchShardTaskStats;
import org.opensearch.search.backpressure.stats.SearchTaskStats;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: java doc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More Java doc has been added for SearchBackPressureStatsCollector and SearchBackPressureStatsCollectorTests

@sbcd90 sbcd90 merged commit e0ea1da into opensearch-project:main Jun 24, 2023
@khushbr khushbr added backport 2.x v2.11.0 Issues targeting release v2.11.0 labels Oct 5, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 5, 2023
* SearchBackPressure Collector added

Signed-off-by: CoderJeffrey <[email protected]>
(cherry picked from commit e0ea1da)
khushbr pushed a commit that referenced this pull request Oct 5, 2023
* SearchBackPressure Collector added

Signed-off-by: CoderJeffrey <[email protected]>
(cherry picked from commit e0ea1da)

Co-authored-by: Jeffrey Liu <[email protected]>
khushbr added a commit to khushbr/performance-analyzer that referenced this pull request Oct 6, 2023
khushbr added a commit that referenced this pull request Oct 6, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x v2.11.0 Issues targeting release v2.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants