Skip to content

Commit e7d76b0

Browse files
committed
Updating README
1 parent 00d1ae1 commit e7d76b0

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

opamp-client/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,56 @@
33
Java implementation of the OpAMP
44
client [spec](https://github.com/open-telemetry/opamp-spec/blob/main/specification.md).
55

6+
> [!WARNING]
7+
> This is an incubating feature. Breaking changes can happen on a new release without previous
8+
> notice and without backward compatibility guarantees.
9+
10+
## Usage
11+
12+
```java
13+
// Initializing it
14+
15+
RequestService requestService = HttpRequestService.create(OkHttpSender.create("[OPAMP_SERVICE_URL]"));
16+
// RequestService requestService = WebSocketRequestService.create(OkHttpWebSocket.create("[OPAMP_SERVICE_URL]")); // Use this instead to connect to the server via WebSocket.
17+
OpampClient client =
18+
OpampClient.builder()
19+
.putIdentifyingAttribute("service.name", "My service name")
20+
.enableRemoteConfig()
21+
.setRequestService(requestService)
22+
.build(
23+
new OpampClient.Callbacks() {
24+
@Override
25+
public void onConnect() {}
26+
27+
@Override
28+
public void onConnectFailed(@Nullable Throwable throwable) {}
29+
30+
@Override
31+
public void onErrorResponse(ServerErrorResponse errorResponse) {}
32+
33+
@Override
34+
public void onMessage(MessageData messageData) {
35+
AgentRemoteConfig remoteConfig = messageData.getRemoteConfig();
36+
if (remoteConfig != null) {
37+
// A remote config was received
38+
39+
// After applying it...
40+
client.setRemoteConfigStatus(
41+
new RemoteConfigStatus.Builder()
42+
.status(RemoteConfigStatuses.RemoteConfigStatuses_APPLIED)
43+
.build());
44+
}
45+
}
46+
});
47+
48+
// State update
49+
client.setAgentDescription(new AgentDescription.Builder().build());
50+
51+
// App shutdown
52+
client.close();
53+
54+
```
55+
656
## Component owners
757

858
- [Cesar Munoz](https://github.com/LikeTheSalad), Elastic

0 commit comments

Comments
 (0)