Add component-level diagnostics to API #80
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of elastic/elastic-agent#2141 and elastic/elastic-agent#2140
This PR contains a few changes:
level
field to theActionRequest
message type that tags the action as acting on either a unit or the whole component. This contains three level types, with the first beingALL
in order to make sure that older non-compatible clients will behave in the expected way. Right now, only diagnostics care about this field.tryPerformDiagnostics
to support thelevel
field; diagnostics that are registered at the client-level become associated with thecomponent
level, and diagnostics registered with a unit become associated with theunit
level.RegisterOptionalDiagnosticHook()
. These optional diagnostics are triggered by corresponding tag in theparams
field of theActionRequest
message.DiagnosticParams
that allows the diagnostic actions to take advantage of theparams
field in a standardized way.Additional things to consider:
DiagnosticParams
in additional ways while we're here; there's easily a few forward-looking field we could add, but right now this was strictly focused on supporting optional CPU profiling.ActionRequest
changes with the goal of making changes both non-breaking and relatively consistent with other parts of the API, but I'm not particularly happy with stuff likeIf level=component, then the consumer should ignore the unit_id and unit_type fields
. My other idea was to break apart theActionRequest
message into different types entirely, perhaps with a different API request for diagnostics, as opposed to the currently strategy of using a single API call for actions and diagnostics. That, however, would be a much larger change.