-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
APPSERV-47 Adds Custom Watches to Monitoring Console #4463
Changes from 14 commits
6fa0a93
96c57cb
1d592a1
102f7f2
7b87e25
92d6b04
65bab00
70afe69
0ca228d
56ad00e
917e10f
a6627c4
a7a870a
653ddac
9d4f419
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,10 @@ public enum Level { | |
public boolean isLessSevereThan(Level other) { | ||
return ordinal() > other.ordinal(); | ||
} | ||
|
||
public static fish.payara.monitoring.alert.Alert.Level parse(String level) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the full canonical name necessary here? I can't see a conflicting import, and neither does my IDE There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope. good catch. |
||
return valueOf(level.toUpperCase()); | ||
} | ||
} | ||
|
||
public static final class Frame implements Iterable<SeriesDataset> { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,10 @@ | |
*/ | ||
package fish.payara.monitoring.alert; | ||
|
||
import javax.json.Json; | ||
import javax.json.JsonObject; | ||
import javax.json.JsonValue; | ||
|
||
import fish.payara.monitoring.alert.Alert.Level; | ||
import fish.payara.monitoring.model.SeriesLookup; | ||
import fish.payara.monitoring.model.Metric; | ||
|
@@ -137,4 +141,30 @@ public String toString() { | |
} | ||
return str.toString(); | ||
} | ||
|
||
public JsonValue toJSON() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this class already exists, but a description of what it's used for wouldn't go amiss - circumstance isn't an intuitive name to me in the context of alerts (in comparison to something like event). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added javadoc. |
||
if (isUnspecified()) { | ||
return JsonValue.NULL; | ||
} | ||
return Json.createObjectBuilder() | ||
.add("level", level.name().toLowerCase()) | ||
.add("start", start.toJSON()) | ||
.add("stop", stop.toJSON()) | ||
.add("suppress", suppress.toJSON()) | ||
.add("suppressing", suppressing == null ? JsonValue.NULL : suppressing.toJSON()) | ||
.build(); | ||
} | ||
|
||
public static Circumstance fromJson(JsonValue value) { | ||
if (value == JsonValue.NULL || value == null) { | ||
return Circumstance.UNSPECIFIED; | ||
} | ||
JsonObject obj = value.asJsonObject(); | ||
return new Circumstance( | ||
Level.parse(obj.getString("level")), | ||
Condition.fromJSON(obj.get("start")), | ||
Condition.fromJSON(obj.get("stop")), | ||
Metric.fromJSON(obj.get("suppressing")), | ||
Condition.fromJSON(obj.get("suppress"))); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB. I opted for a parameter for each action. This could also be done by adding a general parameter
watch
for the name anddata
for the JSON and another parameteraction
or so. But I found this easier to use. On the other hand these are not really intended to be used manually. They mainly exist so that the service can run them to update the config. Manual use is possible but will take a restart to take effect.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they're not for manual use you can prepend them with an underscore (or two underscores, can't remember) to hide them as options on the command line (but not from REST).