- java.lang.Object
-
- aeonics.entity.Entity
-
- aeonics.manager.Manager.Type
-
- aeonics.manager.Monitor
-
- All Implemented Interfaces:
Exportable,Snapshotable
public abstract class Monitor extends Manager.Type
This manager can be used to record monitoring information.It allows to accumulate values over time, based on a four-level deep hyerarchy. Every time a metric is updated, an individual counter is also incremented. This means that you have two values available: the accumulated total and the count.
The hyerarchy is usually composed by
Entity.category()>Object.getClass()>Entity.id()>metricin order to group the different metrics in a structured fashion. Meanwhile, all hyerarchy levels are plain string and allows for custom values.Implementations may choose to have a time window system or else. Implementations should make sure that it can be used in a thread safe way unless it is designed otherwise voluntarily.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMonitor.MonitorTimer-
Nested classes/interfaces inherited from interface aeonics.util.Snapshotable
Snapshotable.SnapshotMode
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringUNSPECIFIED
-
Constructor Summary
Constructors Constructor Description Monitor()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidadd(java.lang.String level1, java.lang.String level2, java.lang.String level3, java.lang.String level4, long value)Increments the counter of the provied entity by 1 and the accumulated value by the specified amount.voidcount(Entity entity)Increments the counter of the provided entity by 1.voidcount(Entity entity, long value)Increments the counter of the provided entity by 1 and the accumulated value by the specified amount.voidcount(Entity entity, java.lang.String metric, long value)Increments the counter of the provided entity by 1 and the accumulated value by the specified amount.<T extends Entity>
voidcount(T entity, java.lang.Class<? super T> groupBy)Increments the counter of the provied entity by 1.<T extends Entity>
voidcount(T entity, java.lang.Class<? super T> groupBy, long value)Increments the counter of the provied entity by 1 and the accumulated value by the specified amount.<T extends Entity>
voidcount(T entity, java.lang.Class<? super T> groupBy, java.lang.String metric, long value)Increments the counter of the provied entity by 1 and the accumulated value by the specified amount.voidcountFor(Entity entity, Entity related)Increments the counter of the provied entity by 1 with the last level being the id of the related entity.voidcountFor(Entity entity, Entity related, long value)Increments the counter of the provied entity by 1 and the accumulated value by the specified amount with the last level being the id of the related entity.<T extends Entity>
voidcountFor(T entity, Entity related, java.lang.Class<? super T> groupBy)Increments the counter of the provied entity by 1 with the last level being the id of the related entity.<T extends Entity>
voidcountFor(T entity, Entity related, java.lang.Class<? super T> groupBy, long value)Increments the counter of the provied entity by 1 and the accumulated value by the specified amount with the last level being the id of the related entity.static Monitorget()Returns the current active instance of this manager type.java.lang.Class<? extends Manager.Type>manager()Hardcoded manager type<T extends Entity>
Monitor.MonitorTimerms(T entity)Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed milliseconds.<T extends Entity>
Monitor.MonitorTimerms(T entity, java.lang.Class<? super T> groupBy)Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed milliseconds.<T extends Entity>
Monitor.MonitorTimerms(T entity, java.lang.Class<? super T> groupBy, java.lang.String metric)Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed milliseconds.<T extends Entity>
Monitor.MonitorTimerms(T entity, java.lang.String metric)Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed milliseconds.<T extends Entity>
Monitor.MonitorTimerms(T entity, java.lang.String groupBy, java.lang.String metric)Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed milliseconds.<T extends Entity>
Monitor.MonitorTimerns(T entity)Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed nanoseconds.<T extends Entity>
Monitor.MonitorTimerns(T entity, java.lang.Class<? super T> groupBy)Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed nanoseconds.<T extends Entity>
Monitor.MonitorTimerns(T entity, java.lang.Class<? super T> groupBy, java.lang.String metric)Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed nanoseconds.<T extends Entity>
Monitor.MonitorTimerns(T entity, java.lang.String metric)Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed nanoseconds.<T extends Entity>
Monitor.MonitorTimerns(T entity, java.lang.String groupBy, java.lang.String metric)Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed nanoseconds.Datareport()Returns all counters and accumulated values.Datareport(Entity entity)Returns counters and accumulated values for all metrics of the given entity.abstract Datareport(java.lang.String level1, java.lang.String level2, java.lang.String level3, java.lang.String level4)Returns the counter and accumulated value of the specified metric.-
Methods inherited from class aeonics.manager.Manager.Type
category, internal, snapshotMode
-
Methods inherited from class aeonics.entity.Entity
addRelation, addRelation, addRelation, cast, clearRelation, config, context, countRelations, countRelations, defineRelation, equals, export, firstRelation, hashCode, hasRelation, id, internal, name, name, onCreate, onRemove, onUpdate, parameter, relations, relationships, removeRelation, snapshot, template, type, valueOf, valueOf
-
-
-
-
Field Detail
-
UNSPECIFIED
public static final java.lang.String UNSPECIFIED
- See Also:
- Constant Field Values
-
-
Method Detail
-
manager
public final java.lang.Class<? extends Manager.Type> manager()
Hardcoded manager type- Specified by:
managerin classManager.Type- Returns:
- the type of manager
-
get
public static Monitor get()
Returns the current active instance of this manager type.- Returns:
- the current active instance of this manager type
-
count
public void count(Entity entity)
Increments the counter of the provided entity by 1.- Level 1: entity category
- Level 2: entity class name
- Level 3: entity id
- Level 4: "hit"
- Counter value: +1
- Accumulated value: 0
- Parameters:
entity- the target entity- See Also:
add(String, String, String, String, long)
-
count
public void count(Entity entity, long value)
Increments the counter of the provided entity by 1 and the accumulated value by the specified amount.- Level 1: entity category
- Level 2: entity class name
- Level 3: entity id
- Level 4: "hit"
- Counter value: +1
- Accumulated value: the provided value
- Parameters:
entity- the target entityvalue- the accumulated value- See Also:
add(String, String, String, String, long)
-
count
public void count(Entity entity, java.lang.String metric, long value)
Increments the counter of the provided entity by 1 and the accumulated value by the specified amount.- Level 1: entity category
- Level 2: entity class name
- Level 3: entity id
- Level 4: the specified metric
- Counter value: +1
- Accumulated value: the provided value
- Parameters:
entity- the target entitymetric- the metric namevalue- the accumulated value- See Also:
add(String, String, String, String, long)
-
count
public <T extends Entity> void count(T entity, java.lang.Class<? super T> groupBy)
Increments the counter of the provied entity by 1.- Level 1: entity category
- Level 2: the group by type
- Level 3: entity id
- Level 4: "hit"
- Counter value: +1
- Accumulated value: 0
- Type Parameters:
T- the entity class type- Parameters:
entity- the target entitygroupBy- a superclass of the entity to group metrics together- See Also:
add(String, String, String, String, long)
-
count
public <T extends Entity> void count(T entity, java.lang.Class<? super T> groupBy, long value)
Increments the counter of the provied entity by 1 and the accumulated value by the specified amount.- Level 1: entity category
- Level 2: the group by type
- Level 3: entity id
- Level 4: "hit"
- Counter value: +1
- Accumulated value: the provided value
- Type Parameters:
T- the entity class type- Parameters:
entity- the target entitygroupBy- a superclass of the entity to group metrics togethervalue- the accumulated value- See Also:
add(String, String, String, String, long)
-
count
public <T extends Entity> void count(T entity, java.lang.Class<? super T> groupBy, java.lang.String metric, long value)
Increments the counter of the provied entity by 1 and the accumulated value by the specified amount.- Level 1: entity category
- Level 2: the group by type
- Level 3: entity id
- Level 4: the specified metric
- Counter value: +1
- Accumulated value: the provided value
- Type Parameters:
T- the entity class type- Parameters:
entity- the target entitygroupBy- a superclass of the entity to group metrics togethermetric- the metric namevalue- the accumulated value- See Also:
add(String, String, String, String, long)
-
ms
public <T extends Entity> Monitor.MonitorTimer ms(T entity)
Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed milliseconds.This method should be used in a
try...withstatement:try( MonitorTimer ms = Monitor.ms(...) ) { ... }- Level 1: entity category
- Level 2: entity class name
- Level 3: entity id
- Level 4: "ms"
- Counter value: +1
- Accumulated value: elapsed milliseconds
- Type Parameters:
T- the entity type- Parameters:
entity- the target entity- Returns:
- an auto closeable object to be used in a
try...withstatement
-
ms
public <T extends Entity> Monitor.MonitorTimer ms(T entity, java.lang.String metric)
Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed milliseconds.This method should be used in a
try...withstatement:try( MonitorTimer ms = Monitor.ms(...) ) { ... }- Level 1: entity category
- Level 2: entity class name
- Level 3: entity id
- Level 4: the provided metric
- Counter value: +1
- Accumulated value: elapsed milliseconds
- Type Parameters:
T- the entity type- Parameters:
entity- the target entitymetric- the target metric- Returns:
- an auto closeable object to be used in a
try...withstatement
-
ms
public <T extends Entity> Monitor.MonitorTimer ms(T entity, java.lang.Class<? super T> groupBy)
Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed milliseconds.This method should be used in a
try...withstatement:try( MonitorTimer ms = Monitor.ms(...) ) { ... }- Level 1: entity category
- Level 2: the group by type
- Level 3: entity id
- Level 4: "ms"
- Counter value: +1
- Accumulated value: elapsed milliseconds
- Type Parameters:
T- the entity type- Parameters:
entity- the target entitygroupBy- the group by type- Returns:
- an auto closeable object to be used in a
try...withstatement
-
ms
public <T extends Entity> Monitor.MonitorTimer ms(T entity, java.lang.Class<? super T> groupBy, java.lang.String metric)
Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed milliseconds.This method should be used in a
try...withstatement:try( MonitorTimer ms = Monitor.ms(...) ) { ... }- Level 1: entity category
- Level 2: the group by type
- Level 3: entity id
- Level 4: the provided metric
- Counter value: +1
- Accumulated value: elapsed milliseconds
- Type Parameters:
T- the entity type- Parameters:
entity- the target entitygroupBy- the group by typemetric- the target metric- Returns:
- an auto closeable object to be used in a
try...withstatement
-
ms
public <T extends Entity> Monitor.MonitorTimer ms(T entity, java.lang.String groupBy, java.lang.String metric)
Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed milliseconds.This method should be used in a
try...withstatement:try( MonitorTimer ms = Monitor.ms(...) ) { ... }- Level 1: entity category
- Level 2: the group by string
- Level 3: entity id
- Level 4: the provided metric
- Counter value: +1
- Accumulated value: elapsed milliseconds
- Type Parameters:
T- the entity type- Parameters:
entity- the target entitygroupBy- the group by stringmetric- the target metric- Returns:
- an auto closeable object to be used in a
try...withstatement
-
ns
public <T extends Entity> Monitor.MonitorTimer ns(T entity)
Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed nanoseconds.This method should be used in a
try...withstatement:try( MonitorTimer ns = Monitor.ns(...) ) { ... }- Level 1: entity category
- Level 2: entity class name
- Level 3: entity id
- Level 4: "ns"
- Counter value: +1
- Accumulated value: elapsed nanoseconds
- Type Parameters:
T- the entity type- Parameters:
entity- the target entity- Returns:
- an auto closeable object to be used in a
try...withstatement
-
ns
public <T extends Entity> Monitor.MonitorTimer ns(T entity, java.lang.String metric)
Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed nanoseconds.This method should be used in a
try...withstatement:try( MonitorTimer ns = Monitor.ns(...) ) { ... }- Level 1: entity category
- Level 2: entity class name
- Level 3: entity id
- Level 4: the provided metric
- Counter value: +1
- Accumulated value: elapsed nanoseconds
- Type Parameters:
T- the entity type- Parameters:
entity- the target entitymetric- the target metric- Returns:
- an auto closeable object to be used in a
try...withstatement
-
ns
public <T extends Entity> Monitor.MonitorTimer ns(T entity, java.lang.Class<? super T> groupBy)
Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed nanoseconds.This method should be used in a
try...withstatement:try( MonitorTimer ns = Monitor.ns(...) ) { ... }- Level 1: entity category
- Level 2: the group by type
- Level 3: entity id
- Level 4: "ns"
- Counter value: +1
- Accumulated value: elapsed nanoseconds
- Type Parameters:
T- the entity type- Parameters:
entity- the target entitygroupBy- the group by type- Returns:
- an auto closeable object to be used in a
try...withstatement
-
ns
public <T extends Entity> Monitor.MonitorTimer ns(T entity, java.lang.Class<? super T> groupBy, java.lang.String metric)
Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed nanoseconds.This method should be used in a
try...withstatement:try( MonitorTimer ns = Monitor.ns(...) ) { ... }- Level 1: entity category
- Level 2: the group by type
- Level 3: entity id
- Level 4: the provided metric
- Counter value: +1
- Accumulated value: elapsed nanoseconds
- Type Parameters:
T- the entity type- Parameters:
entity- the target entitygroupBy- the group by typemetric- the target metric- Returns:
- an auto closeable object to be used in a
try...withstatement
-
ns
public <T extends Entity> Monitor.MonitorTimer ns(T entity, java.lang.String groupBy, java.lang.String metric)
Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed nanoseconds.This method should be used in a
try...withstatement:try( MonitorTimer ns = Monitor.ns(...) ) { ... }- Level 1: entity category
- Level 2: the group by string
- Level 3: entity id
- Level 4: the provided metric
- Counter value: +1
- Accumulated value: elapsed nanoseconds
- Type Parameters:
T- the entity type- Parameters:
entity- the target entitygroupBy- the group by stringmetric- the target metric- Returns:
- an auto closeable object to be used in a
try...withstatement
-
countFor
public void countFor(Entity entity, Entity related)
Increments the counter of the provied entity by 1 with the last level being the id of the related entity. This is useful to track back usage. Example: how many times did a "Fisher" entity interact with a "Lake" entity.- Level 1: entity category
- Level 2: entity class name
- Level 3: entity id
- Level 4: related entity id
- Counter value: +1
- Accumulated value: 0
- Parameters:
entity- the target entityrelated- the related entity- See Also:
add(String, String, String, String, long)
-
countFor
public void countFor(Entity entity, Entity related, long value)
Increments the counter of the provied entity by 1 and the accumulated value by the specified amount with the last level being the id of the related entity. This is useful to track back usage. Example: how many fish did a "Fisher" entity capture in a "Lake" entity.- Level 1: entity category
- Level 2: entity class name
- Level 3: entity id
- Level 4: related entity id
- Counter value: +1
- Accumulated value: the provided value
- Parameters:
entity- the target entityrelated- the related entityvalue- the accumulated value- See Also:
add(String, String, String, String, long)
-
countFor
public <T extends Entity> void countFor(T entity, Entity related, java.lang.Class<? super T> groupBy)
Increments the counter of the provied entity by 1 with the last level being the id of the related entity. This is useful to track back usage. Example: how many times did a "Fisher" entity interact with a "Lake" entity.- Level 1: entity category
- Level 2: the group by type
- Level 3: entity id
- Level 4: related entity id
- Counter value: +1
- Accumulated value: 0
- Type Parameters:
T- the entity class type- Parameters:
entity- the target entityrelated- the related entitygroupBy- a superclass of the entity to group metrics together- See Also:
add(String, String, String, String, long)
-
countFor
public <T extends Entity> void countFor(T entity, Entity related, java.lang.Class<? super T> groupBy, long value)
Increments the counter of the provied entity by 1 and the accumulated value by the specified amount with the last level being the id of the related entity. This is useful to track back usage. Example: how many fish did a "Fisher" entity capture in a "Lake" entity.- Level 1: entity category
- Level 2: the group by type
- Level 3: entity id
- Level 4: related entity id
- Counter value: +1
- Accumulated value: the provided value
- Type Parameters:
T- the entity class type- Parameters:
entity- the target entityrelated- the related entitygroupBy- a superclass of the entity to group metrics togethervalue- the accumulated value- See Also:
add(String, String, String, String, long)
-
add
public abstract void add(java.lang.String level1, java.lang.String level2, java.lang.String level3, java.lang.String level4, long value)Increments the counter of the provied entity by 1 and the accumulated value by the specified amount. Levels might beUNSPECIFIEDto target a higher group by level, but must not benull.Levels should ideally always be alphanumeric lower case to account for case invariant or other remote monitoring systems
- Counter value: +1
- Accumulated value: the provided value
- Parameters:
level1- the first hyerarchy level (usually an entity category)level2- the second hyerarchy level (usually the entity class name)level3- the third hyerarchy level (usually the entity id)level4- the fourth hyerarchy level (usually a specific metric name)value- the accumulated value
-
report
public Data report()
Returns all counters and accumulated values.- Level 1: null
- Level 2: null
- Level 3: null
- Level 4: null
- Returns:
- all counters and accumulated values
-
report
public Data report(Entity entity)
Returns counters and accumulated values for all metrics of the given entity.- Level 1: entity category
- Level 2: entity class name
- Level 3: entity id
- Level 4: null
- Parameters:
entity- the target entity- Returns:
- counters and accumulated values for all metrics of the given entity
-
report
public abstract Data report(java.lang.String level1, java.lang.String level2, java.lang.String level3, java.lang.String level4)
Returns the counter and accumulated value of the specified metric. Levels may benullto specify a wildcard value for that level (meaning all).Levels should ideally always be alphanumeric lower case to account for case invariant or other remote monitoring systems
- Parameters:
level1- the first hyerarchy level (usually an entity category)level2- the second hyerarchy level (usually the entity class name)level3- the third hyerarchy level (usually the entity id)level4- the fourth hyerarchy level (usually a specific metric name)- Returns:
- the counter and accumulated value of the specified metric
-
-