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

Use enum field for HotThreads report type #77812

Merged

Conversation

grcevski
Copy link
Contributor

Backport of #77462

HotThreads report type field is currently declared as a String, but internally it is used as an enum. This PR changes the report type to enum and does a small refactor to encapsulate the getter function with the accumulator class.

I also extended the HotThreads unit tests to test some of the newly refactored code.

Note: This change introduces slight behaviour difference. Previously when the HotThreads API was called with an incorrect report type, e.g. /_nodes/hot_threads?type=gpu we'd crash with InvalidArgumentException, but after argument validation, therefore producing an empty 400 response. After this change we get a 400 with response: "reason": "type not supported [gpu]"

Backport of elastic#77462.

HotThreads report request type was declared as String, but used as an
enum where only few values were allowed. This PR changes the type to
enum allowing malformed requests to correctly report the error.

This PR also introduces a small refactor to make the report getter
function part of the accumulator class.
@grcevski grcevski added >enhancement :Core/Infra/Core Core issues without another label backport Team:Core/Infra Meta label for core/infra team labels Sep 15, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@grcevski grcevski merged commit 4176187 into elastic:7.x Sep 16, 2021
@grcevski grcevski deleted the enhancement/hotthreads_enum_type_backport branch September 16, 2021 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport :Core/Infra/Core Core issues without another label >enhancement Team:Core/Infra Meta label for core/infra team v7.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants