Skip to content

[OpAMP client] Added health reporting support#2867

Open
robsunday wants to merge 12 commits into
open-telemetry:mainfrom
robsunday:opam-client-health-reporting
Open

[OpAMP client] Added health reporting support#2867
robsunday wants to merge 12 commits into
open-telemetry:mainfrom
robsunday:opam-client-health-reporting

Conversation

@robsunday
Copy link
Copy Markdown
Contributor

@robsunday robsunday commented May 26, 2026

Add support for reporting component health to the OpAMP server.
The following actions have to be taken to report agent's health:

  1. Enable health reporting by calling OpampClientBuilder#enableHealthReporting()
  2. Call OpampClientBuilder#setHealth(ComponentHealth health) or OpampClient#setHealth(ComponentHealth health)
  3. New health report should be sent every time agent failure/recovery happen by calling OpampClient#setHealth(ComponentHealth health). Original agent start time should be preserved.

Copilot AI review requested due to automatic review settings May 26, 2026 14:38
@robsunday robsunday requested a review from a team as a code owner May 26, 2026 14:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for reporting agent health (ComponentHealth) to the OpAMP server, exposing a new setHealth API and a corresponding builder configuration.

Changes:

  • Introduces State.Health observable state, HealthAppender, and Field.HEALTH plumbed through OpampClientState and AgentToServerAppenders.
  • Adds OpampClient.setHealth(...) and OpampClientBuilder.enableHealthReporting() / setHealthState(...) APIs.
  • Adds unit tests for the new health appender and client behavior.

Reviewed changes

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

Show a summary per file
File Description
opamp-client/src/main/java/io/opentelemetry/opamp/client/OpampClient.java New setHealth method on the public client interface.
opamp-client/src/main/java/io/opentelemetry/opamp/client/OpampClientBuilder.java Builder support for enabling health reporting and supplying a State.Health.
opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/impl/OpampClientImpl.java Wires HealthAppender, registers HEALTH as compressable, implements setHealth.
opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/impl/OpampClientState.java Adds State.Health field to client state.
opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/impl/recipe/AgentToServerAppenders.java Registers the new HealthAppender.
opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/impl/recipe/appenders/HealthAppender.java New appender writing ComponentHealth into AgentToServer.
opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/request/Field.java New HEALTH field enum value.
opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/state/State.java New Health observable state class.
opamp-client/src/test/java/.../OpampClientImplTest.java Tests for health initialization, sending, and setter.
opamp-client/src/test/java/.../OpampClientStateTest.java Adds health mock field.
opamp-client/src/test/java/.../AgentToServerAppendersTest.java Verifies HEALTH-to-appender mapping.
opamp-client/src/test/java/.../HealthAppenderTest.java Unit tests for HealthAppender.

Comment thread opamp-client/src/main/java/io/opentelemetry/opamp/client/OpampClientBuilder.java Outdated
@robsunday robsunday requested a review from Copilot May 26, 2026 16:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

@robsunday robsunday requested a review from Copilot May 27, 2026 09:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Comment thread opamp-client/src/main/java/io/opentelemetry/opamp/client/OpampClientBuilder.java Outdated
robsunday and others added 3 commits May 27, 2026 12:05
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@LikeTheSalad LikeTheSalad left a comment

Choose a reason for hiding this comment

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

Thank you, @robsunday 🙏

It looks good overall, and it follows the same patterns as other fields. Thank you for keeping that consistency. I only have some comments regarding the default value for this new field.

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

@Override
public void setHealth(@Nonnull ComponentHealth health) {
if (!Objects.equals(state.health.get(), health)) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

[for reviewer] I think this needs to be refactored because it is not really thread safe. Other thread may manipulate the state between state.health.get() and state.health.set() calls.
I'm thinking about adding boolean update(@Nonnull T value) method to State interface. It would do atomic get and set, and return true if value was updated, so OpampClientImpl can call addFieldAndSend if value was changed.

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.

Sounds good. I just think it'd be a bit strange to have 2 methods that set the state's value. Maybe the atomic update could be done in the existing set, and change its signature to return a boolean.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

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.

Cheers! I already approved your changes, so we just have to wait for one of the repo maintainers to have a look.

Copy link
Copy Markdown
Contributor

@LikeTheSalad LikeTheSalad left a comment

Choose a reason for hiding this comment

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

Thanks again, @robsunday 🙏

@robsunday
Copy link
Copy Markdown
Contributor Author

Thanks for quick reviews @LikeTheSalad !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants