-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
4bcf114
commit 04a724c
Showing
29 changed files
with
906 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...ocelot-config/src/main/java/rocks/inspectit/ocelot/commons/models/health/AgentHealth.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package rocks.inspectit.ocelot.commons.models.health; | ||
|
||
import ch.qos.logback.classic.Level; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
/** | ||
* Represents the health status of an individual agent. | ||
*/ | ||
@RequiredArgsConstructor | ||
public enum AgentHealth { | ||
|
||
OK("the agent is working properly"), | ||
|
||
WARNING("the agent has warning messages"), | ||
|
||
ERROR("the agent has encountered errors"); | ||
|
||
private final String description; | ||
|
||
/** | ||
* Decides whether this health status is more severe or equal to the passed one. | ||
* {@code null} is always considered less severe. | ||
* | ||
* @param other The health to compare with | ||
* | ||
* @return {@code true} if both health status are equal or this is more severe than other; {@code false} otherwise. | ||
*/ | ||
public boolean isMoreSevereOrEqualTo(AgentHealth other) { | ||
return other != null ? compareTo(other) >= 0 : true; | ||
} | ||
|
||
/** | ||
* Compares multiple health status and returns the one that is most severe. | ||
* | ||
* @param status The array of health status to compare (may contain {@code null}) | ||
* | ||
* @return That health of the passed ones that is more severe. {@code null} if none is passed. | ||
*/ | ||
public static AgentHealth mostSevere(AgentHealth... status) { | ||
AgentHealth max = null; | ||
|
||
for (AgentHealth curr : status) { | ||
if (curr != null && curr.isMoreSevereOrEqualTo(max)) { | ||
max = curr; | ||
} | ||
} | ||
|
||
return max; | ||
} | ||
|
||
/** | ||
* Determines the agent health based on the level of a log event that occurred (e.g., WARN level corresponds with WARNING). | ||
* | ||
* @param logLevel The log level that occurred | ||
* | ||
* @return The agent health that corresponds to the log level. | ||
*/ | ||
public static AgentHealth fromLogLevel(Level logLevel) { | ||
if (logLevel.isGreaterOrEqual(Level.ERROR)) { | ||
return ERROR; | ||
} else if (logLevel.isGreaterOrEqual(Level.WARN)) { | ||
return WARNING; | ||
} else { | ||
return OK; | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return name() + " (" + description + ")"; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...src/main/java/rocks/inspectit/ocelot/config/model/selfmonitoring/AgentHealthSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package rocks.inspectit.ocelot.config.model.selfmonitoring; | ||
|
||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.NonNull; | ||
|
||
import javax.validation.constraints.AssertFalse; | ||
import java.time.Duration; | ||
|
||
/** | ||
* Defines the settings for the agent status. | ||
*/ | ||
@Data | ||
@NoArgsConstructor | ||
public class AgentHealthSettings { | ||
|
||
/** | ||
* The period during which a non-ok and non-instrumentation-related status is valid. | ||
* Status changes due to instrumentation errors are valid until the next re-instrumentation. | ||
*/ | ||
@NonNull | ||
private Duration validityPeriod; | ||
|
||
@AssertFalse(message = "The specified period should not be negative!") | ||
public boolean isNegativeDuration() { | ||
return validityPeriod != null && validityPeriod.isNegative(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ inspectit: | |
|
||
self-monitoring: | ||
enabled: false | ||
agent-status: | ||
validity-period: 1h | ||
|
||
log-preloading: | ||
enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...lot-core/src/main/java/rocks/inspectit/ocelot/core/config/PropertySourcesReloadEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package rocks.inspectit.ocelot.core.config; | ||
|
||
import org.springframework.context.ApplicationEvent; | ||
|
||
/** | ||
* This event is fired whenever the set of {@link org.springframework.context.annotation.PropertySource}s is to be reloaded. | ||
* In contrast to {@link PropertySourcesChangedEvent}, this event fires <b>before</b> the reload process. | ||
*/ | ||
public class PropertySourcesReloadEvent extends ApplicationEvent { | ||
|
||
PropertySourcesReloadEvent(Object source) { | ||
super(source); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.