Package io.mats3.localinspect
Class LocalStatsMatsInterceptor
java.lang.Object
io.mats3.localinspect.LocalStatsMatsInterceptor
- All Implemented Interfaces:
MatsInitiateInterceptor
,MatsInitiateInterceptor.MatsInitiateInterceptOutgoingMessages
,MatsStageInterceptor
,MatsStageInterceptor.MatsStageInterceptOutgoingMessages
public class LocalStatsMatsInterceptor
extends Object
implements MatsStageInterceptor.MatsStageInterceptOutgoingMessages, MatsInitiateInterceptor.MatsInitiateInterceptOutgoingMessages
Interceptor that collects "local stats" for Initiators and Stages of Endpoints, which can be used in conjunction with
a MatsFactory report generator,
LocalHtmlInspectForMatsFactory
.
To install, invoke the install(MatsInterceptable)
method, supplying the MatsFactory. The report generator
will fetch the interceptor from the MatsFactory.
Implementation note: Mats allows Initiators and Endpoints to be defined "runtime" - there is no specific setup
time vs. run time. This implies that the set of Endpoints and Initiators in a MatsFactory can increase from one run
of a report generation to the next (Endpoint may even be deleted, but this is really only meant for testing).
Moreover, this stats collecting class only collects stats for Initiators and Endpoints that have had traffic, since
it relies on the interceptors API. This means that while the MatsFactory might know about an Initiator or an
Endpoint, this stats class might not yet have picked it up. This is why all methods return Optional. On the other
hand, the set of Stages of an endpoint cannot change after it has been finishedSetup()
(and it cannot be start()
'ed before it has been
finishedSetup()
) - thus if e.g. only the initial stage of an Endpoint has so far seen traffic, this
class has nevertheless created stats objects for all of the Endpoint's stages.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static class
static interface
static class
static interface
static interface
static interface
static class
static interface
Nested classes/interfaces inherited from interface io.mats3.api.intercept.MatsInitiateInterceptor
MatsInitiateInterceptor.InitiateCompletedContext, MatsInitiateInterceptor.InitiateInterceptContext, MatsInitiateInterceptor.InitiateInterceptOutgoingMessagesContext, MatsInitiateInterceptor.InitiateInterceptUserLambdaContext, MatsInitiateInterceptor.InitiateStartedContext, MatsInitiateInterceptor.MatsInitiateInterceptOutgoingMessages, MatsInitiateInterceptor.MatsInitiateInterceptUserLambda
Nested classes/interfaces inherited from interface io.mats3.api.intercept.MatsStageInterceptor
MatsStageInterceptor.MatsStageInterceptOutgoingMessages, MatsStageInterceptor.MatsStageInterceptUserLambda, MatsStageInterceptor.StageCommonContext, MatsStageInterceptor.StageCompletedContext, MatsStageInterceptor.StageInterceptContext, MatsStageInterceptor.StageInterceptOutgoingMessageContext, MatsStageInterceptor.StageInterceptUserLambdaContext, MatsStageInterceptor.StagePreprocessAndDeserializeErrorContext, MatsStageInterceptor.StageReceivedContext
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiongetEndpointStats
(MatsEndpoint<?, ?> matsEndpoint) getInitiatorStats
(MatsInitiator matsInitiator) getStageStats
(MatsStage<?, ?, ?> matsStage) void
void
initiateInterceptOutgoingMessages
(MatsInitiateInterceptor.InitiateInterceptOutgoingMessagesContext context) static LocalStatsMatsInterceptor
install
(MatsInterceptable matsInterceptableMatsFactory) Creates an instance of this interceptor and installs it on the providedMatsInterceptable
(which most probably is aMatsFactory
).void
Invoked after the stage is fully completed, outgoing messages sent, db and messaging system committed.void
void
Invoked right after message have been received, preprocessed and deserialized, before invoking the user lambda.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.mats3.api.intercept.MatsInitiateInterceptor
initiateStarted
Methods inherited from interface io.mats3.api.intercept.MatsStageInterceptor
stageCompletedNextDirect, stagePreprocessAndDeserializeError
-
Field Details
-
DEFAULT_NUM_SAMPLES
public static final int DEFAULT_NUM_SAMPLES- See Also:
-
MAX_NUMBER_OF_DYNAMIC_ENTRIES
public static final int MAX_NUMBER_OF_DYNAMIC_ENTRIESThis is an Out Of Memory avoidance in case of wrongly used initiatorIds. These are not supposed to be dynamic, but there is nothing hindering a user from creating a new initiatorId per initiation. Thus, if we go above a certain number of such entries, we stop adding. Value is 500.- See Also:
-
EXTRA_STATE_REQUEST_NANOS
- See Also:
-
EXTRA_STATE_REQUEST_NODENAME
- See Also:
-
EXTRA_STATE_ENDPOINT_ENTER_NANOS
- See Also:
-
EXTRA_STATE_ENDPOINT_ENTER_NODENAME
- See Also:
-
EXTRA_STATE_OR_SIDELOAD_INITIATOR_NANOS
- See Also:
-
EXTRA_STATE_OR_SIDELOAD_INITIATOR_NODENAME
- See Also:
-
-
Method Details
-
install
Creates an instance of this interceptor and installs it on the providedMatsInterceptable
(which most probably is aMatsFactory
). Note that this interceptor is stateful wrt. the MatsFactory, thus a new instance is needed per MatsFactory - which is fulfilled using this method. It should only be invoked once per MatsFactory. You get the created interceptor in return, but that is not needed when employed withLocalHtmlInspectForMatsFactory
, as that will fetch the instance from the MatsFactory usingMatsInterceptable.getInitiationInterceptor(Class)
.- Parameters:
matsInterceptableMatsFactory
- theMatsInterceptable
MatsFactory to add it to.
-
getInitiatorStats
public Optional<LocalStatsMatsInterceptor.InitiatorStats> getInitiatorStats(MatsInitiator matsInitiator) -
getEndpointStats
public Optional<LocalStatsMatsInterceptor.EndpointStats> getEndpointStats(MatsEndpoint<?, ?> matsEndpoint) -
getStageStats
-
initiateInterceptOutgoingMessages
public void initiateInterceptOutgoingMessages(MatsInitiateInterceptor.InitiateInterceptOutgoingMessagesContext context) - Specified by:
initiateInterceptOutgoingMessages
in interfaceMatsInitiateInterceptor.MatsInitiateInterceptOutgoingMessages
-
initiateCompleted
- Specified by:
initiateCompleted
in interfaceMatsInitiateInterceptor
-
stageReceived
Description copied from interface:MatsStageInterceptor
Invoked right after message have been received, preprocessed and deserialized, before invoking the user lambda. (If any error occurs during preprocess or deserialization, thenMatsStageInterceptor.stagePreprocessAndDeserializeError(StagePreprocessAndDeserializeErrorContext)
is invoked instead).- Specified by:
stageReceived
in interfaceMatsStageInterceptor
-
stageInterceptOutgoingMessages
public void stageInterceptOutgoingMessages(MatsStageInterceptor.StageInterceptOutgoingMessageContext context) - Specified by:
stageInterceptOutgoingMessages
in interfaceMatsStageInterceptor.MatsStageInterceptOutgoingMessages
-
stageCompleted
Description copied from interface:MatsStageInterceptor
Invoked after the stage is fully completed, outgoing messages sent, db and messaging system committed. You cannot anymore modify any outgoing messages etc - for this, implementMatsStageInterceptor.MatsStageInterceptOutgoingMessages
.- Specified by:
stageCompleted
in interfaceMatsStageInterceptor
- See Also:
-