- 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()
>metric
in 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.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
UNSPECIFIED
-
Constructor Summary
Constructors Constructor Description Monitor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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.void
count(Entity entity)
Increments the counter of the provided entity by 1.void
count(Entity entity, long value)
Increments the counter of the provided entity by 1 and the accumulated value by the specified amount.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.<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.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.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.<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.java.lang.Class<? extends Manager.Type>
manager()
Hardcoded manager type<T extends Entity>
java.lang.AutoCloseablems(T entity)
Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed milliseconds.<T extends Entity>
java.lang.AutoCloseablems(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>
java.lang.AutoCloseablems(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>
java.lang.AutoCloseablems(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>
java.lang.AutoCloseablems(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>
java.lang.AutoCloseablens(T entity)
Increments the counter of the provied entity by 1 and the accumulated value by the number of elapsed nanoseconds.<T extends Entity>
java.lang.AutoCloseablens(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>
java.lang.AutoCloseablens(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>
java.lang.AutoCloseablens(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>
java.lang.AutoCloseablens(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.Data
report()
Returns all counters and accumulated values.Data
report(Entity entity)
Returns counters and accumulated values for all metrics of the given entity.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.-
Methods inherited from class aeonics.manager.Manager.Type
category, internal
-
Methods inherited from class aeonics.entity.Entity
addRelation, addRelation, addRelation, cast, clearRelation, config, defineRelation, equals, export, firstRelation, hashCode, hasRelation, id, name, name, onCreate, onRemove, onUpdate, parameter, relations, relationships, removeRelation, snapshot, 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:
manager
in classManager.Type
- Returns:
- the type of manager
-
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> java.lang.AutoCloseable 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...with
statement:try( AutoCloseable 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...with
statement
-
ms
public <T extends Entity> java.lang.AutoCloseable 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...with
statement:try( AutoCloseable 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...with
statement
-
ms
public <T extends Entity> java.lang.AutoCloseable 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...with
statement:try( AutoCloseable 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...with
statement
-
ms
public <T extends Entity> java.lang.AutoCloseable 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...with
statement:try( AutoCloseable 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...with
statement
-
ms
public <T extends Entity> java.lang.AutoCloseable 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...with
statement:try( AutoCloseable 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...with
statement
-
ns
public <T extends Entity> java.lang.AutoCloseable 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...with
statement:try( AutoCloseable ms = 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...with
statement
-
ns
public <T extends Entity> java.lang.AutoCloseable 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...with
statement:try( AutoCloseable ms = 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...with
statement
-
ns
public <T extends Entity> java.lang.AutoCloseable 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...with
statement:try( AutoCloseable ms = 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...with
statement
-
ns
public <T extends Entity> java.lang.AutoCloseable 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...with
statement:try( AutoCloseable ms = 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...with
statement
-
ns
public <T extends Entity> java.lang.AutoCloseable 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...with
statement:try( AutoCloseable ms = 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...with
statement
-
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 beUNSPECIFIED
to 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 benull
to 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
-
-