Skip to content

[opamp-client] Add the ability to receive custom messages#2990

Open
breedx-splk wants to merge 7 commits into
open-telemetry:mainfrom
breedx-splk:add_custom_message_ability
Open

[opamp-client] Add the ability to receive custom messages#2990
breedx-splk wants to merge 7 commits into
open-telemetry:mainfrom
breedx-splk:add_custom_message_ability

Conversation

@breedx-splk

Copy link
Copy Markdown
Contributor

The OpAMP protocol declares the ability to support custom messages.

This PR adds this custom capability. For users, it will look something like this:

OpampClient client =
      OpampClient.builder()
          .addCustomCapability("com.example.pause")
          .build(
              new OpampClient.Callbacks() {
                @Override
                public void onMessage(OpampClient client, MessageData messageData) {
                  CustomMessage customMessage = messageData.getCustomMessage();
                  if (customMessage != null) {
                    if ("com.example.pause".equals(customMessage.capability)
                        && "pause".equals(customMessage.type)) {
                      byte[] payload = customMessage.data.toByteArray();
                      // do the dew...
                    }
                  }
                }
                // ((other message handling omitted))
              });

Disclaimer: made mostly with codex...but I support it.

Copilot AI review requested due to automatic review settings July 14, 2026 00:18
@breedx-splk
breedx-splk requested a review from a team as a code owner July 14, 2026 00:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds OpAMP “custom messages” support to the opamp-client by letting clients advertise supported custom capabilities in AgentToServer.custom_capabilities, and by surfacing ServerToAgent.custom_message through the existing onMessage callback payload.

Changes:

  • Introduces builder support for reporting custom capabilities (addCustomCapability) and plumbs this through client state and request field mapping.
  • Extends MessageData and response handling so ServerToAgent.custom_message triggers Callbacks.onMessage(...) with a populated customMessage.
  • Adds/updates tests to validate custom capabilities reporting and custom message callback behavior.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
opamp-client/src/test/java/io/opentelemetry/opamp/client/internal/impl/recipe/AgentToServerAppendersTest.java Updates appender mapping test to include CUSTOM_CAPABILITIES.
opamp-client/src/test/java/io/opentelemetry/opamp/client/internal/impl/OpampClientStateTest.java Updates state test wiring to include State.CustomCapabilities.
opamp-client/src/test/java/io/opentelemetry/opamp/client/internal/impl/OpampClientImplTest.java Adds tests for sending custom capabilities and receiving custom messages.
opamp-client/src/main/java/io/opentelemetry/opamp/client/OpampClientBuilder.java Adds addCustomCapability(...) and includes custom capabilities in initial state.
opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/state/State.java Adds State.CustomCapabilities state holder with new Field type.
opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/response/MessageData.java Extends callback payload to include CustomMessage.
opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/request/Field.java Adds CUSTOM_CAPABILITIES request field identifier.
opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/impl/recipe/AgentToServerAppenders.java Wires a new appender slot for CUSTOM_CAPABILITIES.
opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/impl/OpampClientState.java Adds custom capabilities to the aggregated client state.
opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/impl/OpampClientImpl.java Adds compression/wiring for custom capabilities and handles custom_message in responses.
Comments suppressed due to low confidence (1)

opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/response/MessageData.java:17

  • The class-level Javadoc says this message data is for "status changes", but MessageData now also carries custom messages. Updating the wording would make the API clearer for callback implementers.
/**
 * Data class provided in {@link OpampClient.Callbacks#onMessage(OpampClient, MessageData)} with
 * Server's provided status changes.
 */

@LikeTheSalad LikeTheSalad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you! 🙏 just a minor comment, not a blocker. Also, thanks for the example of how to use it.

Comment thread opamp-client/src/main/java/io/opentelemetry/opamp/client/OpampClientBuilder.java Outdated
Comment thread opamp-client/src/main/java/io/opentelemetry/opamp/client/OpampClientBuilder.java Outdated

@jackshirazi jackshirazi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

some minor comments

breedx-splk and others added 4 commits July 15, 2026 08:28
…nal/impl/OpampClientImplTest.java

Co-authored-by: jackshirazi <jacks@fasterj.com>
…ClientBuilder.java

Co-authored-by: jackshirazi <jacks@fasterj.com>
…nal/impl/recipe/appenders/CustomCapabilitiesAppender.java

Co-authored-by: jackshirazi <jacks@fasterj.com>
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.

4 participants