Currently, eventgate-wikimedia has custom code to set a few defaults in event data from HTTP request headers. Instead of manually specifying the headers to set, we could add properties explicitly to the schema that should be set by eventgate if they are not already in the event data. Example:
http: type: object description: Information about the HTTP request that generated an event. properties: request_headers: type: object description: Request headers sent by the client. additionalProperties: type: string properties: user-agent: type: string referer: type: string x-client-ip: type: string
Here, request_headers is still a 'map type', as it has additionalProperties with a specific type. However, some specific keys are defined. eventgate-wikimedia could use this fact to automatically set the values to the corresponding HTTP header. Something like
for property in http.request_headers.properties { if (req.headers[property.to_lower_case()] && !event.http.request_headers[property]) { event.http.request_headers[property] = req.headers[property.to_lower_case()] } }
This would allow us to get rid of header specific custom code in eventgate-wikimedia, while giving control over what headers are automatically set to schema owners, without forcing them to have their producer code set the header in the event data (and ultimately send the same data twice over the same HTTP request)).
We'd need to make sure any JSONSchema converter code knows to still interpret objects with additionalProperties and type: string as a map even if properties are also defined.