Augmenting RequestLog Data
In some cases, you may need to store data in a request log entry that cannot be easily collected by collectors invoked from the targeting valve. This data is often not required for targeting, but may be necessary for custom analysis or other use cases. To support these scenarios, you can store additional data directly in the request log entry.
Storing Custom Data in a Request Log Entry
To add custom data to a request log entry, use the following approach:
private void storeValueAtKey(String key, Object value) { TargetingState state = TargetingStateProvider.get(); RequestLogEntry entry = state.getRequestLogEntry(); Map<String, Object> data = entry.getData(); data.put(key, value); }
- Ensure that the
keyyou use is unique to avoid collisions with other code that may also store data in the request log. - The
valueobject must be a Plain Old Java Object (POJO) that can be serialized to and from JSON usingcom.fasterxml.jackson.databind.ObjectMapper.
Considerations
- The data you store will be serialized and written to the request log, which is then persisted in the Request Relevance Data Store.
- Do not store large objects in the request log entry. Storing large objects can negatively impact performance and increase storage requirements.
Store only the data necessary for your analysis or integration to maintain system performance and reliability.