flagr
flagr copied to clipboard
Add entityId to EntityContext for evaluating constraints
In rolling out a recent feature, I had a case where I wanted to white / black list particular entity IDs from being distributed to the new feature. It would be handy for Flagr to include the entity ID in the entity context when evaluating constraints, to enable this. I'm unsure how the property should be named; 'id', 'entityId', 'entity_id', etc.
Expected Behavior
You should be able to set a constraint that evaluates the entity ID of the flagr evaluate request.
Current Behavior
Flagr only includes properties explicitly included in the entityContext
parameter of eval requests.
Possible Solution
Around https://github.com/checkr/flagr/blob/master/pkg/handler/eval.go#L239, before sending the entity context, add an 'id' field containing the value of the entity ID passed in.
How about @entityID
? We can even extend this convention to something else that can be derived from the request. The camel case naming is from https://checkr.github.io/flagr/api_docs/#tag/evaluation
@entityID
@entityType
@timestamp
...
Some open questions to consider for records logging:
- Do we include these as entityContext for flagr records logging?
- And since we are already logging these, which means simply putting these into entityContext will have duplicate logging of the evaluation result.
I like the idea of @<field>
, and including the other fields as well for more flexibility!
Stale issue message