@StableMinor(version="12.5", sinceVersion="9.0") public interface IMonitor extends AutoCloseable
The monitoring data will be saved:
closed
.
closed
and
the transaction ends (either by a successful commit or by a rollback).
Either way, the save action will be a non-thread-blocking action (it will happen in a background processing). Also, the save action might not be performed immediately.
Example for monitoring an event that is unbound to a transaction:
In this case, the monitoring data will be saved when the monitor is closed.try(IMonitor monitor = ManagerFactory.getMonitorManager().monitor("myEventKey")) { // add some monitoring values monitor.addValues("myField", value); monitor.addValues("myOtherField", otherValue); }
Example including duration measure and transaction awareness:
In this case, the monitoring data will be saved when the transaction is commited (or rolledback) and the monitor is closed.try(ITransaction transaction = ...) { transaction.begin(); ... try(IMonitor monitor = ManagerFactory.getMonitorManager().monitor("myEventKey", transaction); { monitor.start(); ... // if wanted, other monitoring values may be added: monitor.addValues("myField", value); } transaction.commit(); }
The monitoring data is stored in the form of value providers
,
which are responsible for providing monitor data when required.
Thus, even when calling methods for adding raw values (addValues(String, Serializable...)
, for example),
they will be stored in the form of value providers
.
IMonitorValuesProvider
Modifier and Type | Method and Description |
---|---|
IMonitor |
addValues(IMonitorValuesProvider... values)
Adds the given value providers in this monitor.
|
default IMonitor |
addValues(Map<String,List<? extends Serializable>> fieldValues)
Adds the given values for the given fields in this monitor.
|
default IMonitor |
addValues(String fieldId,
List<? extends Serializable> values)
Adds the given values for the given field in this monitor.
|
default IMonitor |
addValues(String fieldId,
Serializable... values)
Adds the given values for the given field in this monitor.
|
void |
close()
Closes this monitor instance.
If this monitor is not bound to a transaction, the collected data will be saved in this moment. If this monitor is bound to a transaction, the data will be saved either: If the transaction this monitor is bound to has already been closed, the data will be saved in this moment. Otherwise, the data will be saved in the moment the transaction is closed. If start() has been called but stop() hasn't, stop() will be called automatically. |
default IMonitor |
setDuration(long duration)
Adds value of
duration field . |
default IMonitor |
setDuration(long startMillis,
long endMillis)
Adds value of
duration field . |
IMonitor |
start()
Method used to indicate that the monitored event has started.
|
IMonitor |
stop()
Method used to indicate that the monitored event has ended.
|
IMonitor start()
duration field
.
The duration is calculated by the difference of this call and the call to
either stop()
or close()
(the first to be called).
The stop()
method must be called to indicate the end of
the event. If stop()
isn't called, it will be called automatically in
close()
.stop()
IMonitor stop()
start()
must have been called previously.
This method calls setDuration(long, long)
to add duration value relative to the use between the start and stop
calls.
addValues(Map)
,
start()
default IMonitor setDuration(long startMillis, long endMillis)
duration field
.startMillis
- the start of the event in milliseconds since midnight
January 1, 1970 GMT.endMillis
- the end of the event in milliseconds since midnight
January 1, 1970 GMT.default IMonitor setDuration(long duration)
duration field
.startMillis
- the start of the event in milliseconds since midnight
January 1, 1970 GMT.endMillis
- the end of the event in milliseconds since midnight
January 1, 1970 GMT.default IMonitor addValues(String fieldId, Serializable... values)
fieldId
- the field identifier.values
- field values.default IMonitor addValues(String fieldId, List<? extends Serializable> values)
fieldId
- the field identifier.values
- field values.default IMonitor addValues(Map<String,List<? extends Serializable>> fieldValues)
fieldValues
- the field values.IMonitor addValues(IMonitorValuesProvider... values)
values
- the value providers.void close()
start()
has been called but stop()
hasn't, stop()
will be called automatically.close
in interface AutoCloseable
LumisXP 12.5.0.200928 - Copyright © 2006–2020 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.