public class MatsMicrometerInterceptor
extends java.lang.Object
implements io.mats3.api.intercept.MatsInterceptable.MatsMetricsInterceptor, io.mats3.api.intercept.MatsInitiateInterceptor, io.mats3.api.intercept.MatsStageInterceptor
MeterRegistry, it will employ this to create the metrics on, otherwise it employs the
Metrics.globalRegistry.
Meters included are for these different phases:
Timers or DistributionSummarys -
Remember that counts are also implicitly present:
Execution: Init or stage:
"mats.exec.total" Total time taken to execute init or stage."mats.exec.userlambda" Part of total exec time taken for the
actual user lambda itself from start to finish, which thus includes any external IO like e.g. DB or HTTP calls the
user code performs, minus any time taken to construct outbound Mats messages. Any use
'ctx.log[Timing]Measurement(..)' within user lambda, to break out e.g. metrics for any potentially expensive IO, is
available as 'mats.exec.ops.time.' and 'mats.exec.ops.measure.' metrics.""mats.exec.out" Part of total exec time taken to produce and send
messages: Produce, serialize and compress all DTOs, STOs and message envelopes, and produce and send all system
messages."mats.exec.out.quantity" Number of outgoing messages from
execution."mats.exec.db.commit" Part of total time taken to commit
database."mats.exec.msgsys.commit" Part of total time taken to
commit message system."mats.exec.ops.time." If user adds timings, it will be added as a
metric with this prefix."mats.exec.ops.measure." If user adds measurements, it will be
added as a metric with this prefix."mats.in.total" Total time taken to preprocess and deserialize
incoming message."mats.out.total" Total time taken to produce, serialize and compress
DTO, STO and message envelope, and produce and send system message"mats.out.msgsys" From out total, time taken to produce and
send message."mats.out.envelope" Outgoing mats envelope full size."mats.out.wire" Outgoing mats envelope wire size."appName" AppName for "this" service."appVersion" AppVersion for "this" service."exec" Whether "init" or "stage""initiatingAppName" AppName of the service which initiated the Mats Flow"initiatorId" Which initiatorId initiated this Mats Flow"initOrStageId" Used for both InitiatorId or StageId - "this" initiatorId (for
inits) or stageId (for stages)."stageIndex" For stages, return the stage index, i.e. "0" for initial stage, "1" for
stage1, etc. Reads "" (empty string) for initiations."type" (Only for message metrics, both sent and received) the
MatsOutgoingMessage.MessageType for the incoming/outgoing message."from" (Only for received messages) from which initiatorId or stageId the message
came."to" (Only for sent messages) which stageId this message is targeting.false): If this is true, then tags will be added to the meters which will
give higher semantic resolution and more information, but which might result in a quite substantial number of time
series - if you have a popular Mats endpoint with many stages targeted by many other services (thus getting many
differing 'from', 'initiatingAppName' and 'initiatorId'), you may get a "cardinality explosion", in particular if you
also configure histograms. It is thus false by default, i.e. when using the
single-arg install(..) method.false:
true, and then use a Micrometer MeterFilter to tweak the tags
with more precision than this all-or-nothing approach, e.g. include "initiatingAppName" and "initiatorId" for
specific endpoints or stages.
This is not the case with the 'mats-intercept-logging' plugin, as that records all such meta info (and quite a bit
more) on each log line. You can thus "after the fact" decide on what slicing you want the measures to be divided
along. The negative is that this requires quite substantial amount of storage.
Notice the class MatsMicrometerInterceptor.SuggestedTimingHistogramsMeterFilter, which configures the timing-specific metrics
with hopefully relevant histograms. You may apply this as such:Metrics.globalRegistry.config().meterFilter(new SuggestedTimingHistogramsMeterFilter());MeterFilter logic of
Micrometer.
Note: This interceptor (Micrometer Metrics) has special support in JmsMatsFactory: If present on the
classpath, it is automatically installed using the install(MatsInterceptableMatsFactory) install method.
This implies that it employs the Micrometer 'globalRegistry' - and 'includeAllTags'
will be false. If you rather want to supply a specific registry, or change the 'includeAllTags' boolean
value, then create and install a specific instance of this class using the
install(MatsInterceptableMatsFactory, MeterRegistry, boolean) method - the JmsMatsFactory will
then remove the automatically installed, since it implements the special marker-interface
MatsInterceptable.MatsMetricsInterceptor of which there can only be one instance installed. (In a Spring context where the
MatsFactory is created for you using an annotation, you are still able to do this during early phases of Spring
initialization: E.g. inject a reference to the MatsInterceptable (the MatsFactory) and just install the
new instance. This is possible since the Micrometer meters are lazily created when initiations are performed and Mats
Stages receives messages. The decision of which tags are in use is therefore not needed until right before the
service becomes operational, that is, performs inits and receives messages.)| Modifier and Type | Class and Description |
|---|---|
static class |
MatsMicrometerInterceptor.SuggestedTimingHistogramsMeterFilter
A
MeterFilter that applies a hopefully reasonable histogram to all Timer meters. |
io.mats3.api.intercept.MatsInitiateInterceptor.InitiateCompletedContext, io.mats3.api.intercept.MatsInitiateInterceptor.InitiateInterceptContext, io.mats3.api.intercept.MatsInitiateInterceptor.InitiateInterceptOutgoingMessagesContext, io.mats3.api.intercept.MatsInitiateInterceptor.InitiateInterceptUserLambdaContext, io.mats3.api.intercept.MatsInitiateInterceptor.InitiateStartedContext, io.mats3.api.intercept.MatsInitiateInterceptor.MatsInitiateInterceptOutgoingMessages, io.mats3.api.intercept.MatsInitiateInterceptor.MatsInitiateInterceptUserLambdaio.mats3.api.intercept.MatsStageInterceptor.MatsStageInterceptOutgoingMessages, io.mats3.api.intercept.MatsStageInterceptor.MatsStageInterceptUserLambda, io.mats3.api.intercept.MatsStageInterceptor.StageCommonContext, io.mats3.api.intercept.MatsStageInterceptor.StageCompletedContext, io.mats3.api.intercept.MatsStageInterceptor.StageInterceptContext, io.mats3.api.intercept.MatsStageInterceptor.StageInterceptOutgoingMessageContext, io.mats3.api.intercept.MatsStageInterceptor.StageInterceptUserLambdaContext, io.mats3.api.intercept.MatsStageInterceptor.StagePreprocessAndDeserializeErrorContext, io.mats3.api.intercept.MatsStageInterceptor.StageReceivedContext| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
LOG_PREFIX |
static int |
MAX_NUMBER_OF_METRICS
This is a cardinality-explosion-avoidance limit in case of wrongly used initiatorIds.
|
static java.lang.String |
MEASURE_EXEC_OPS_PREFIX |
static java.lang.String |
QUANTITY_EXEC_OUT_DESC |
static java.lang.String |
QUANTITY_EXEC_OUT_NAME |
static java.lang.String |
SIZE_OUT_ENVELOPE_DESC |
static java.lang.String |
SIZE_OUT_ENVELOPE_NAME |
static java.lang.String |
SIZE_OUT_WIRE_DESC |
static java.lang.String |
SIZE_OUT_WIRE_NAME |
static java.lang.String |
TAG_APP_NAME |
static java.lang.String |
TAG_APP_VERSION |
static java.lang.String |
TAG_EXEC |
static java.lang.String |
TAG_FROM |
static java.lang.String |
TAG_INIT_OR_STAGE_ID |
static java.lang.String |
TAG_INITIATING_APP_NAME |
static java.lang.String |
TAG_INITIATOR_ID |
static java.lang.String |
TAG_STAGE_ID |
static java.lang.String |
TAG_STAGE_INDEX |
static java.lang.String |
TAG_TO |
static java.lang.String |
TAG_TYPE |
static java.lang.String |
TIMER_EXEC_DB_COMMIT_DESC |
static java.lang.String |
TIMER_EXEC_DB_COMMIT_NAME |
static java.lang.String |
TIMER_EXEC_MSGSYS_COMMIT_DESC |
static java.lang.String |
TIMER_EXEC_MSGSYS_COMMIT_NAME |
static java.lang.String |
TIMER_EXEC_OPS_PREFIX |
static java.lang.String |
TIMER_EXEC_OUT_DESC |
static java.lang.String |
TIMER_EXEC_OUT_NAME |
static java.lang.String |
TIMER_EXEC_TOTAL_DESC |
static java.lang.String |
TIMER_EXEC_TOTAL_NAME |
static java.lang.String |
TIMER_EXEC_USER_LAMBDA_DESC |
static java.lang.String |
TIMER_EXEC_USER_LAMBDA_NAME |
static java.lang.String |
TIMER_IN_TOTAL_DESC |
static java.lang.String |
TIMER_IN_TOTAL_NAME |
static java.lang.String |
TIMER_OUT_MSGSYS_SEND_DESC |
static java.lang.String |
TIMER_OUT_MSGSYS_SEND_NAME |
static java.lang.String |
TIMER_OUT_TOTAL_DESC |
static java.lang.String |
TIMER_OUT_TOTAL_NAME |
static java.lang.String |
UNIT_BYTES |
| Modifier and Type | Method and Description |
|---|---|
void |
initiateCompleted(io.mats3.api.intercept.MatsInitiateInterceptor.InitiateCompletedContext ctx) |
static MatsMicrometerInterceptor |
install(io.mats3.api.intercept.MatsInterceptableMatsFactory matsInterceptableMatsFactory)
Creates a
MatsMicrometerInterceptor employing the provided globalRegistry,
and installs it as a singleton on the provided MatsInterceptableMatsFactory |
static MatsMicrometerInterceptor |
install(io.mats3.api.intercept.MatsInterceptableMatsFactory matsInterceptableMatsFactory,
io.micrometer.core.instrument.MeterRegistry meterRegistry,
boolean includeAllTags)
Creates a
MatsMicrometerInterceptor employing the provided MeterRegistry, and installs it as a
singleton on the provided MatsInterceptableMatsFactory |
void |
stageCompleted(io.mats3.api.intercept.MatsStageInterceptor.StageCompletedContext ctx) |
void |
stageReceived(io.mats3.api.intercept.MatsStageInterceptor.StageReceivedContext ctx) |
public static final java.lang.String LOG_PREFIX
public static final java.lang.String TIMER_EXEC_TOTAL_NAME
public static final java.lang.String TIMER_EXEC_TOTAL_DESC
public static final java.lang.String TIMER_EXEC_USER_LAMBDA_NAME
public static final java.lang.String TIMER_EXEC_USER_LAMBDA_DESC
public static final java.lang.String TIMER_EXEC_OUT_NAME
public static final java.lang.String TIMER_EXEC_OUT_DESC
public static final java.lang.String QUANTITY_EXEC_OUT_NAME
public static final java.lang.String QUANTITY_EXEC_OUT_DESC
public static final java.lang.String TIMER_EXEC_DB_COMMIT_NAME
public static final java.lang.String TIMER_EXEC_DB_COMMIT_DESC
public static final java.lang.String TIMER_EXEC_MSGSYS_COMMIT_NAME
public static final java.lang.String TIMER_EXEC_MSGSYS_COMMIT_DESC
public static final java.lang.String TIMER_EXEC_OPS_PREFIX
public static final java.lang.String MEASURE_EXEC_OPS_PREFIX
public static final java.lang.String TIMER_IN_TOTAL_NAME
public static final java.lang.String TIMER_IN_TOTAL_DESC
public static final java.lang.String TIMER_OUT_TOTAL_NAME
public static final java.lang.String TIMER_OUT_TOTAL_DESC
public static final java.lang.String TIMER_OUT_MSGSYS_SEND_NAME
public static final java.lang.String TIMER_OUT_MSGSYS_SEND_DESC
public static final java.lang.String SIZE_OUT_ENVELOPE_NAME
public static final java.lang.String SIZE_OUT_ENVELOPE_DESC
public static final java.lang.String SIZE_OUT_WIRE_NAME
public static final java.lang.String SIZE_OUT_WIRE_DESC
public static final java.lang.String TAG_APP_NAME
public static final java.lang.String TAG_APP_VERSION
public static final java.lang.String TAG_EXEC
public static final java.lang.String TAG_TYPE
public static final java.lang.String TAG_INITIATING_APP_NAME
public static final java.lang.String TAG_INITIATOR_ID
public static final java.lang.String TAG_STAGE_ID
public static final java.lang.String TAG_INIT_OR_STAGE_ID
public static final java.lang.String TAG_STAGE_INDEX
public static final java.lang.String TAG_FROM
public static final java.lang.String TAG_TO
public static final java.lang.String UNIT_BYTES
public static final int MAX_NUMBER_OF_METRICS
public static MatsMicrometerInterceptor install(io.mats3.api.intercept.MatsInterceptableMatsFactory matsInterceptableMatsFactory, io.micrometer.core.instrument.MeterRegistry meterRegistry, boolean includeAllTags)
MatsMicrometerInterceptor employing the provided MeterRegistry, and installs it as a
singleton on the provided MatsInterceptableMatsFactorymatsInterceptableMatsFactory - the MatsInterceptable to install on (probably a MatsFactory.meterRegistry - the Micrometer MeterRegistry to create meters on.includeAllTags - whether all tags should be included (which may easily result in very many time series) or not.MatsMicrometerInterceptor instance which was installed as singleton.public static MatsMicrometerInterceptor install(io.mats3.api.intercept.MatsInterceptableMatsFactory matsInterceptableMatsFactory)
MatsMicrometerInterceptor employing the provided globalRegistry,
and installs it as a singleton on the provided MatsInterceptableMatsFactorymatsInterceptableMatsFactory - the MatsInterceptable to install on (probably a MatsFactory.MatsMicrometerInterceptor instance which was installed as singleton.public void initiateCompleted(io.mats3.api.intercept.MatsInitiateInterceptor.InitiateCompletedContext ctx)
initiateCompleted in interface io.mats3.api.intercept.MatsInitiateInterceptorpublic void stageReceived(io.mats3.api.intercept.MatsStageInterceptor.StageReceivedContext ctx)
stageReceived in interface io.mats3.api.intercept.MatsStageInterceptorpublic void stageCompleted(io.mats3.api.intercept.MatsStageInterceptor.StageCompletedContext ctx)
stageCompleted in interface io.mats3.api.intercept.MatsStageInterceptor