Metadata is all the "additional" information that resides with a emitted event, some of which is required information.
In EventFlow metadata is merely a IEnumerable
of
KeyValuePair<string,string>
for which each is a metadata entry.
Out of the box these metadata keys are added to each aggregate event.
event_name
andevent_version
- A name and version for the event which is used during event deserialization.timestamp
- ADateTimeOffset
for when the event was emitted from the aggregate.aggregate_sequence_number
- The version the aggregate was after the event was emitted, e.g.1
for the very first event emitted.
If you require additional information to be stored along with each
event, then you can implement the IMetadataProvider
interface and
register the class using e.g. .AddMetadataProvider(...)
on
EventFlowOptions
.
EventFlow ships with a collection of ready-to-use providers in some of its NuGet packages.
- AddEventTypeMetadataProvider
event_type_assembly_name
- Assembly name of the assembly containing the eventevent_type_assembly_version
- Assembly version of the assembly containing the eventevent_type_fullname
- Full name of the event corresponding toType.FullName
for the aggregate event type.- AddGuidMetadataProvider
guid
- A newGuid
for each event.- AddMachineNameMetadataProvider
environment_machinename
- Adds the machine name handling the event fromEnvironment.MachineName
- AddRequestHeadersMetadataProvider
request_header[HEADER]
- Adds all headers from the OWIN request as metadata, each as a separate entry for whichHEADER
in the is replace with the name of the header. E.g. therequest_header[Connection]
might contain the valueKeep-Alive
.- AddUriMetadataProvider
request_uri
- OWIN request URI.request_method
- OWIN request method.- AddUserHostAddressMetadataProvider
user_host_address
- The provider tries to find the correct user host address by inspecting request headers, i.e., if you have a load balancer in front of your application, then the request IP is not the real user address, but the load balancer should send the user IP as a header.user_host_address_source_header
- The header for of which the user host address was taken.remote_ip_address
- The remote IP address. Note that this might be the IP address of your load balancer.