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

[extension/opamp] Add support for custom messages #32021

Closed
BinaryFissionGames opened this issue Mar 28, 2024 · 4 comments
Closed

[extension/opamp] Add support for custom messages #32021

BinaryFissionGames opened this issue Mar 28, 2024 · 4 comments
Assignees
Labels

Comments

@BinaryFissionGames
Copy link
Contributor

BinaryFissionGames commented Mar 28, 2024

Component(s)

extension/opamp

Is your feature request related to a problem? Please describe.

Some components may provide extra capabilities that can be leveraged by an OpAMP server. In the OpAMP specification, these are codified as custom messages, but there is currently no way for a collector component to take advantage of these custom messages.

Since support for custom messages has been released in the opamp-go library, we should be able to start using them in the opamp extension.

Describe the solution you'd like

The opampextension is the sole communication point between the OpAMP server and the collector. Because of this, it follows that other components that wish to communicate with the OpAMP server will need to do so through the opampextension.

Similar to the storage extension interface, we propose the following interface for interacting with the opampextension:

type CustomMessageCallback func(*protobufs.CustomMessage)

type CustomCapabilityRegistry interface {
    Register(capability string, callback CustomMessageCallback) (CustomCapability, error)
}


type CustomCapability interface {
    SendMessage(messageType string, message []byte) (messageSendingChannel chan struct{}, err error)
    Unregister()
}

Here, opampextension would satisfy the CustomCapabilityRegistry interface, allowing for other components to register the custom capability it supports. The opampextension will then keep track of what capabilities have been registered, and a list of callbacks for each capability, since multiple components may register as supporting the same capability.

The list of supported custom capabilities that the opampextension has will be the union of all unique capability strings registered.

When a custom message for the registered capability is sent from the server to the agent, it is broadcast to all callbacks for the capability. These callbacks are called asynchronously (in their own separate goroutines).

When registering, an object satisfying the CustomCapability interface is returned that can be used to send messages for the custom capability, as well as to unregister the custom capability.

This design allows the registry to keep track internally of which calls to register correspond to which calls of unregister, so that a single instance of a component cannot unregister a capability for a different component. It also restricts sending a message until after the capability has been registered.

Calling SendMessage after Unregister will return an error and the message will not be sent.

The supervisor will simply proxy custom messages between the agent and the OpAMP server, as it does for other messages.

Describe alternatives you've considered

No response

Additional context

No response

@BinaryFissionGames BinaryFissionGames added enhancement New feature or request needs triage New item requiring triage labels Mar 28, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@andykellr
Copy link

For context, I added the CustomMessage feature to opamp-spec and opamp-go and reviewed this proposal with Brandon. Looking forward to feedback.

@BinaryFissionGames
Copy link
Contributor Author

I update the proposal to add:

  1. An error to Register, since SetCustomCapabilities can return an error
  2. Copy the return signature of the OpAMP client for SendMessage, so that the caller can decide how to handle what to do when a custom message is already sending (see the comment on SendCustomMessage for the opamp client)

@evan-bradley evan-bradley added priority:p2 Medium and removed needs triage New item requiring triage labels Apr 2, 2024
evan-bradley pushed a commit that referenced this issue May 3, 2024
**Description:** <Describe what has changed.>
* Adds support for utilizing custom capabilities with the opamp
extension

**Link to tracking Issue:** #32021

**Testing:**
* Unit tests

**Documentation:**
Added some docs for usage to the opamp extension README
@BinaryFissionGames
Copy link
Contributor Author

Closing as completed with #32951

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants