I am using RegistryEventConsumer Bean in order to add event consumers to any Retry instance and logging the event to know how many times a specific endpoint got retried in case of any issues with the endpoint. below is the snippet.
@Bean
public RegistryEventConsumer<Retry> myRetryRegistryEventConsumer() {
return new RegistryEventConsumer<Retry>() {
@Override
public void onEntryAddedEvent(EntryAddedEvent<Retry> entryAddedEvent) {
entryAddedEvent.getAddedEntry().getEventPublisher()
.onEvent(event -> LOG.info(event.toString()));
}
@Override
public void onEntryRemovedEvent(EntryRemovedEvent<Retry> entryRemoveEvent) {
}
@Override
public void onEntryReplacedEvent(EntryReplacedEvent<Retry> entryReplacedEvent) {
}
};
}
Log Entries look like below
2020-10-26T13:00:19.807034700+01:00[Europe/Berlin]: Retry 'backendA', waiting PT1S until attempt '1'. Last attempt failed with exception 'org.abc.exception.MyCustomException: call to http://localhost:8080/endpointA is failed :connect error
2020-10-26T13:00:19.912028800+01:00[Europe/Berlin]: Retry 'backendA', waiting PT2S until attempt '2'. Last attempt failed with exception 'org.abc.exception.MyCustomException: call to http://localhost:8080/endpointA is failed :connect error.
2020-10-26T13:00:20.023250+01:00[Europe/Berlin]: Retry 'backendA' recorded a failed retry attempt. Number of retry attempts: '3'. Giving up. Last exception was: 'org.abc.exception.MyCustomException: call to http://localhost:8080/endpointA is failed :connect error
i would like to log the request input which my endpoint takes(lets say it takes Student object with name , id ,age as input ) along with the event . how to achieve this?
1.a) the expectation is to customize the logging and it should something like below.
Retry 'backendA', waiting PT1S until attempt '1'. Last attempt failed for url http://localhost:8080/endpointA for input : "Student ("Arun", A11,18)" with exception 'org.abc.exception.MyCustomException: call to http://localhost:8080/endpointA is failed :connect error
1.b) and How to capture the metrics?