Structured log pipelines depend on stable field names and types. A producer that silently removes, adds, or changes a field can break dashboards, alerts, and downstream parsers.
Design a LogSchemaDriftDetector class:
LogSchemaDriftDetector() creates a stateless detector.String[] violations(...) reports every difference between an expected and actual schema.boolean isCompatible(...) returns true exactly when no violations exist.
expectedFields[i] has type expectedTypes[i], and actualFields[i] has type actualTypes[i]. Field names and type names are case-sensitive. Input order has no meaning.
Use these exact violation formats:
- Missing expected field:
missing:<field> - Wrong type:
type:<field>:<expectedType>-><actualType> - Unexpected actual field:
unexpected:<field>
Return violations in ascending lexicographic order.
Example 1:
Input:
Output:
Explanation: The actual schema removes message, changes level, and adds trace_id.
Example 2:
Input:
Output:
Explanation: Reordering service and version is valid, but region is unexpected.
Constraints
0 <= expectedFields.length == expectedTypes.length <= 10^40 <= actualFields.length == actualTypes.length <= 10^4- Field names are unique within each schema.
- Field names are non-empty ASCII strings of length at most
100. - Types are one of
string, integer, float, or boolean. - Inputs are not modified.
- At most
100 total method calls are made.