Package org.mockserver.mock.drift
Class DriftAnalyzer
java.lang.Object
org.mockserver.mock.drift.DriftAnalyzer
Compares a real forwarded response against a matching stub expectation's
configured response and emits
DriftRecords for any structural
discrepancies (status code, headers, JSON schema).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidanalyse(Expectation expectation, HttpResponse realResponse) Analyse the real forwarded response against the expectation's stub response.voidcheckPerformanceDrift(String expectationId, long responseTimeMs, long now) Check whether the p95 response time for the given expectation exceeds the configured threshold, and if so emit a PERFORMANCE drift record.static DriftAnalyzervoidsetResponseTimeThresholdMs(long thresholdMs) Set the p95 response time threshold (in milliseconds) above which a PERFORMANCE drift record is emitted.voidsetSemanticExtension(SemanticDriftExtension extension) Set the optional semantic drift extension.
-
Constructor Details
-
DriftAnalyzer
-
-
Method Details
-
setSemanticExtension
Set the optional semantic drift extension. When non-null and available, structural drift records are enriched with LLM-classified severity. -
setResponseTimeThresholdMs
public void setResponseTimeThresholdMs(long thresholdMs) Set the p95 response time threshold (in milliseconds) above which a PERFORMANCE drift record is emitted. Zero or negative disables. -
getInstance
-
analyse
Analyse the real forwarded response against the expectation's stub response. If the expectation's action is not anHttpResponse(e.g. it is a forward action), this method is a no-op.- Parameters:
expectation- the matched expectation (may be null)realResponse- the response received from the upstream service (may be null)
-
checkPerformanceDrift
Check whether the p95 response time for the given expectation exceeds the configured threshold, and if so emit a PERFORMANCE drift record.- Parameters:
expectationId- the expectation to checkresponseTimeMs- the response time just observed (already recorded in PercentileTracker)now- the current epoch time in milliseconds
-