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

Adds the listener for resource utilization metrics #687

Merged
merged 8 commits into from
Jul 23, 2024

Conversation

Gaganjuneja
Copy link
Collaborator

Adds the listener for resource utilization metrics.

  1. RTFPerformanceAnalyzerSearchListener - Emits the CPU_Utilization and Heap_used metrics for task level query shard operations (both query phase and the fetch phase).
  2. RTFPerformanceAnalyzerTransportInterceptor - Emits the CPU_Utilization metric for BulkShardRequest.

Is your feature request related to a problem? Please provide an existing Issue # , or describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you are proposing
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Check List

  • Backport Labels added.
  • 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.

Gagan Juneja added 4 commits July 22, 2024 19:46
Signed-off-by: Gagan Juneja <[email protected]>
Signed-off-by: Gagan Juneja <[email protected]>
Signed-off-by: Gagan Juneja <[email protected]>
Signed-off-by: Gagan Juneja <[email protected]>
Copy link

codecov bot commented Jul 23, 2024

Codecov Report

Attention: Patch coverage is 72.54902% with 70 lines in your changes missing coverage. Please review.

Project coverage is 70.95%. Comparing base (9cb092f) to head (6899623).
Report is 1 commits behind head on main.

Files Patch % Lines
...listener/RTFPerformanceAnalyzerSearchListener.java 64.39% 42 Missing and 5 partials ⚠️
...RTFPerformanceAnalyzerTransportRequestHandler.java 65.21% 11 Missing and 5 partials ⚠️
...performanceanalyzer/PerformanceAnalyzerPlugin.java 33.33% 2 Missing ⚠️
...analyzer/config/PerformanceAnalyzerController.java 0.00% 1 Missing ⚠️
...er/listener/PerformanceAnalyzerSearchListener.java 80.00% 0 Missing and 1 partial ⚠️
...rt/PerformanceAnalyzerTransportRequestHandler.java 80.00% 0 Missing and 1 partial ⚠️
...nsport/RTFPerformanceAnalyzerTransportChannel.java 97.91% 0 Missing and 1 partial ⚠️
...rt/RTFPerformanceAnalyzerTransportInterceptor.java 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #687      +/-   ##
============================================
+ Coverage     70.88%   70.95%   +0.07%     
- Complexity      421      478      +57     
============================================
  Files            49       53       +4     
  Lines          3125     3377     +252     
  Branches        194      217      +23     
============================================
+ Hits           2215     2396     +181     
- Misses          785      844      +59     
- Partials        125      137      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Gagan Juneja <[email protected]>
nishchay21
nishchay21 previously approved these changes Jul 23, 2024
Copy link
Member

@psychbot psychbot left a comment

Choose a reason for hiding this comment

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

There are some code coverage annotations, can we see if those can be addressed.

return isSearchListenerEnabled() ? this : NO_OP_SEARCH_LISTENER;
}

private boolean isSearchListenerEnabled() {
Copy link
Member

Choose a reason for hiding this comment

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

isSearchListenerEnabled seems to be a mandatory method for any SearchListeners implementation. Should we add it to the super class and all the subclasses needs to write the logic of this method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can do that. Didn't want to change a lot the existing stuff as anyways the plan is to bring this into core at some point in time.


private Histogram createCPUUtilizationHistogram() {
MetricsRegistry metricsRegistry = OpenSearchResources.INSTANCE.getMetricsRegistry();
if (metricsRegistry != null) {
Copy link
Member

Choose a reason for hiding this comment

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

If the registry is null it does not make sense to create this listener, Do we need to throw exception instead of returning null?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No. We just want to stay silent.

@@ -108,4 +111,19 @@ public static HashMap<ShardId, IndexShard> getShards() {
IndexShardState.RECOVERING,
IndexShardState.POST_RECOVERY,
IndexShardState.STARTED);

public static double calculateCPUUtilization(
Copy link
Member

Choose a reason for hiding this comment

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

Can we add java doc explaining how we are calculating CPU Utilization

Copy link
Member

Choose a reason for hiding this comment

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

Can the cpuShareFactor be calculated here itself?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No. It's used from 2 places so should be generic.

Signed-off-by: Gagan Juneja <[email protected]>
String operation,
boolean isFailed) {
long overallStartTime = fetchStartTime;
long queryTaskId = threadLocal.get().getOrDefault(QUERY_TASK_ID, 0l);
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 use -1 instead of 0.

Comment on lines 241 to 242
long overallStartTime,
long operationTime,
Copy link
Member

Choose a reason for hiding this comment

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

As these are being used in the context of search we can change operations to phase and change variable names.

overallStartTime -> startTime
operationTime -> phaseTookTime
operation -> phase

Signed-off-by: Gagan Juneja <[email protected]>
Copy link
Member

@psychbot psychbot left a comment

Choose a reason for hiding this comment

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

LGTM!
Do we know the build failure reason and if that needs to be fixed?
If there is no open issue, can we create one and tag it to this PR.

@nishchay21 nishchay21 merged commit c95feb6 into opensearch-project:main Jul 23, 2024
3 of 5 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jul 23, 2024
* Adds the listener for resource utilization metrics

Signed-off-by: Gagan Juneja <[email protected]>
Co-authored-by: Gagan Juneja <[email protected]>
(cherry picked from commit c95feb6)
Gaganjuneja added a commit that referenced this pull request Jul 23, 2024
* Adds the listener for resource utilization metrics

Signed-off-by: Gagan Juneja <[email protected]>
Co-authored-by: Gagan Juneja <[email protected]>
(cherry picked from commit c95feb6)

Co-authored-by: Gagan Juneja <[email protected]>
psychbot pushed a commit that referenced this pull request Jul 26, 2024
* [Feature] adds index_uuid as a tag in node stats all shard metrics (#680) (#689)

* Adds index_uuid as a dimension for node stats col

Signed-off-by: Atharva Sharma <[email protected]>

* updates gauge usage and added index_uuid as tag

Signed-off-by: Atharva Sharma <[email protected]>

* removed incomplete collector

Signed-off-by: Atharva Sharma <[email protected]>

* fixed UTs after gauge changes

Signed-off-by: Atharva Sharma <[email protected]>

* addressed comments

Signed-off-by: Atharva Sharma <[email protected]>

* reverted gauge related changes

Signed-off-by: Atharva Sharma <[email protected]>

---------

Signed-off-by: Atharva Sharma <[email protected]>
(cherry picked from commit 948b54a)

Co-authored-by: Atharva Sharma <[email protected]>

* Adds the listener for resource utilization metrics (#687) (#688)

* Adds the listener for resource utilization metrics

Signed-off-by: Gagan Juneja <[email protected]>
Co-authored-by: Gagan Juneja <[email protected]>
(cherry picked from commit c95feb6)

Co-authored-by: Gagan Juneja <[email protected]>

---------

Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com>
Co-authored-by: Atharva Sharma <[email protected]>
peterzhuamazon pushed a commit that referenced this pull request Jul 29, 2024
* [Feature] adds index_uuid as a tag in node stats all shard metrics (#680) (#689)

* Adds index_uuid as a dimension for node stats col

Signed-off-by: Atharva Sharma <[email protected]>

* updates gauge usage and added index_uuid as tag

Signed-off-by: Atharva Sharma <[email protected]>

* removed incomplete collector

Signed-off-by: Atharva Sharma <[email protected]>

* fixed UTs after gauge changes

Signed-off-by: Atharva Sharma <[email protected]>

* addressed comments

Signed-off-by: Atharva Sharma <[email protected]>

* reverted gauge related changes

Signed-off-by: Atharva Sharma <[email protected]>

---------

Signed-off-by: Atharva Sharma <[email protected]>
(cherry picked from commit 948b54a)

Co-authored-by: Atharva Sharma <[email protected]>

* Adds the listener for resource utilization metrics (#687) (#688)

* Adds the listener for resource utilization metrics

Signed-off-by: Gagan Juneja <[email protected]>
Co-authored-by: Gagan Juneja <[email protected]>
(cherry picked from commit c95feb6)

Co-authored-by: Gagan Juneja <[email protected]>

---------

Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com>
Co-authored-by: Atharva Sharma <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants