What are Custom Metrics?
Custom metrics are user-defined functions that can be integrated into Murnitur Shield to perform unique evaluations on your payloads. These functions take the payload as input and return a tuple consisting of a boolean (indicating whether a trigger occurred) and an optional string (providing the text under evaluation if no trigger was detected).Defining a Custom Metric
To define a custom metric, you need to create a function that matches the expected signature. The function must accept aPayload
object and return a tuple containing a boolean and an optional string.
Here’s an example of a custom metric function:
Registering a Custom Metric
To register a custom metric with Murnitur Shield, use theGuard.register_custom_metric
method. This allows you to integrate custom logic for evaluating your payloads.
length_check
value is registered with the custom_metric_function
, enabling Murnitur Shield to use it during payload evaluations.