Class ValidationMetrics
java.lang.Object
ch.nexsol.gateway.validation.ValidationMetrics
Counts what the validation filter sees, as plain Micrometer meters: the host
application exports them to Prometheus, OpenTelemetry or anything else it already
configures a registry for.
Every tag is drawn from a bounded set — the operations of a contract, the routes of the gateway, a fixed outcome — so the number of series stays proportional to the size of the configuration. The violations themselves are never tagged: they belong in the audit trail and the logs, not in a metric whose cardinality they would blow up.
A gateway with no MeterRegistry bean gets a no-op instance, so the filter works
the same without the actuator on the classpath.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhy a body was forwarded without being held against its schema. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCounter of the bodies that were forwarded without being validated, tagged by the reason.static final StringCounter of the exchanges forwarded without validation because their contract could not be read.static final StringCounter of the validated messages, tagged by direction, route, operation and outcome. -
Constructor Summary
ConstructorsConstructorDescriptionValidationMetrics(io.micrometer.core.instrument.MeterRegistry registry) Creates the meters. -
Method Summary
Modifier and TypeMethodDescriptionvoidbodySkipped(String direction, String routeId, ValidationMetrics.SkipReason reason) Counts one body that was forwarded without being validated.voidcontractUnavailable(String location) Counts one exchange forwarded because its contract could not be read.voidvalidated(String direction, String routeId, String operation, ValidationMode mode, boolean valid) Counts one validated message.
-
Field Details
-
VALIDATIONS
Counter of the validated messages, tagged by direction, route, operation and outcome.- See Also:
-
BODIES_SKIPPED
Counter of the bodies that were forwarded without being validated, tagged by the reason.- See Also:
-
CONTRACTS_UNAVAILABLE
Counter of the exchanges forwarded without validation because their contract could not be read.- See Also:
-
-
Constructor Details
-
ValidationMetrics
public ValidationMetrics(io.micrometer.core.instrument.MeterRegistry registry) Creates the meters.- Parameters:
registry- the registry the meters are published to, ornullto record nothing
-
-
Method Details
-
validated
public void validated(String direction, String routeId, String operation, ValidationMode mode, boolean valid) Counts one validated message.- Parameters:
direction-requestorresponserouteId- the route that handled the exchangeoperation- the contract operation, asMETHOD /templatemode- the mode the direction was validated invalid- whether the message honoured the contract
-
bodySkipped
Counts one body that was forwarded without being validated.- Parameters:
direction-requestorresponserouteId- the route that handled the exchangereason- why the body was not validated
-