kezhenxu94 commented on code in PR #11137:
URL: https://github.com/apache/skywalking/pull/11137#discussion_r1275676857
##########
oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/webhook/WebhookCallback.java:
##########
@@ -39,13 +41,24 @@ public class WebhookCallback extends HttpAlarmCallback {
private final Gson gson = new Gson();
@Override
- public void doAlarm(List<AlarmMessage> alarmMessage) throws IOException,
InterruptedException {
- if (alarmRulesWatcher.getWebHooks().isEmpty()) {
+ public void doAlarm(List<AlarmMessage> alarmMessages) throws IOException,
InterruptedException {
+ Map<String, WebhookSettings> settingsMap =
alarmRulesWatcher.getWebHooks();
+ if (settingsMap == null || settingsMap.isEmpty()) {
return;
}
- for (String url : alarmRulesWatcher.getWebHooks()) {
- post(URI.create(url), gson.toJson(alarmMessage), Map.of());
+ Map<String, List<AlarmMessage>> groupedMessages =
groupMessagesByHook(alarmMessages);
+ for (Map.Entry<String, List<AlarmMessage>> entry :
groupedMessages.entrySet()) {
+ var hookName = entry.getKey();
+ var messages = entry.getValue();
+ var setting = settingsMap.get(hookName);
Review Comment:
~~~The `hookName` from the `groupMessagesByHook(alarmMessages);` is
something like `slackHooks.custom1`, but the keys in `settingsMap` is something
like `custom1`, how can you get the setting with `settingsMap.get(hookName);`?
Did you process the hook name somewhere I missed?~~~
OK just found the key is formatted name with the hook type
And the tests only covers global webhooks, please test the rule-level web
hooks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]