The purpose of the Event Framework is to provide a standard unified architecture to capture all Mojaloop events.
Disclaimer: This is experimental and is being implemented as a PoC. As such the design may change based on the evolution of the PoC's implementation, and any lessons learned.
Events will be produced by utilising a standard common library that will publish events to a sidecar component utilising a light-weight highly performant protocol (e.g. gRPC).
Sidecar module will publish events to a singular Kafka topic that will allow for multiple handlers to consume and process the events as required.
Kafka partitions will be determined by the event-type (e.g. log, audit, trace, errors etc).
Each Mojaloop component will have its own tightly coupled Sidecar.
Event messages will be produced to Kafka using the Trace-Id as the message key. This will ensure that all the messages part of the same trace (transaction) are stored in the same partition in order.
If the value is not present in the destination, it means that the notification was generated by the connected node (server).
to
string
Y
Mandatory for the sender and optional in the destination. The sender can ommit the value of the domain.
pp
string
N
Optional for the sender, when is considered the identity of the session. Is mandatory in the destination if the identity of the originator is different of the identity of the from property.
metadata
object <MessageMetadata>
N
The sender should avoid to use this property to transport any kind of content-related information, but merely data relevant to the context of the communication. Consider to define a new content type if there's a need to include more content information into the message.
type
string
Y
MIME declaration of the content type of the message.
Id for a processing leg identifier for a component or function.
81fa25e8d66d2e88
parentSpanId
16HEXDIGLC
N
The id references the related message.
e457b5a2e4d86bd1
sampled
number
N
Indicator if event message should be included in the trace 1. If excluded it will be left the consumer to decide on sampling.
1
flags
number
N
Indicator if event message should be included in the trace flow. ( Debug 1 - this will override the sampled value )
0
startTimestamp
datetime
N
ISO 8601 with the following format yyyy-MM-dd'T'HH:mm:ss.SSSSSSz. If not included the current timestamp will be taken. Represents the start timestamp of a span.
2015-08-29T11:22:09.815479Z
finishTimestamp
datetime
N
ISO 8601 with the following format yyyy-MM-dd'T'HH:mm:ss.SSSSSSz. If not included the current timestamp will be taken. Represents the finish timestamp of a span
Transaction Id representing either a transfer, quote, etc
659ee338-c8f8-4c06-8aff-944e6c5cd694
transactionType
string
N
The transaction type represented by the transactionId. E.g. (transfer, quote, etc)
transfer
parentEventType
string
N
The event-type of the parent Span.
bulk-prepare
parentEventAction
string
N
The event-action of the parent Span.
prepare
tracestate
string
N
This tag is set if EventSDK environmental variable EVENT_SDK_TRACESTATE_HEADER_ENABLED is true or if parent span context has the tracestate header or tag included. The tag holds updated tracestate header value as per the W3C trace headers specification. More here
congo=t61rcWkgMzE,rojo=00f067aa0ba902b7
<string>
string
N
Arbitary Key-value pair for additional meta-data to be added to the trace information.
Comma delimited vendor specific format captured as follows: <vendor>=<base64-encoded-state>
congo=t61rcWkgMzE,rojo=00f067aa0ba902b7
Note: Before this specification was written, some tracers propagated X-B3-Sampled as true or false as opposed to 1 or 0. While you shouldn't encode X-B3-Sampled as true or false, a lenient implementation may accept them.
Note: (Event-SDK)[https://github.com/mojaloop/event-sdk] since version v9.4.1 has methods to add key value tags in the tracestate, and since version v9.5.2 the tracestate is base64 encoded. To be able to use the tracestate consistently, use matching versions across all services in a system.
Refer to the following publication for more information: https://github.com/apache/incubator-zipkin-b3-propagation
Header
Description
Example
X-B3-TraceId
Encoded as 32 or 16 lower-hex characters.
a 128-bit TraceId header might look like: X-B3-TraceId: 463ac35c9f6413ad48485a3953bb6124. Unless propagating only the Sampling State, the X-B3-TraceId header is required.
X-B3-SpanId
Encoded as 16 lower-hex characters.
a SpanId header might look like: X-B3-SpanId: a2fb4a1d1a96d312. Unless propagating only the Sampling State, the X-B3-SpanId header is required.
X-B3-ParentSpanId
header may be present on a child span and must be absent on the root span. It is encoded as 16 lower-hex characters.
A ParentSpanId header might look like: X-B3-ParentSpanId: 0020000000000001
X-B3-Sampled
An accept sampling decision is encoded as 1 and a deny as 0. Absent means defer the decision to the receiver of this header.
A Sampled header might look like: X-B3-Sampled: 1.
X-B3-Flags
Debug is encoded as 1. Debug implies an accept decision, so don't also send the X-B3-Sampled header.
Refer to Event Envelope Model section. This defines the message that will be sent through the Kafka transport.
Alternatively the tracing context could be stored in Kafka headers which are only supports v0.11 or later. Note that this would break support for older versions of Kafka.
Transfer tracing would be limited to each of the transfer legs (i.e. Prepare and Fulfil) as a result of the Mojaloop API specification not catering for tracing information. The trace information will be send as part of the callbacks by the Switch, but the FSPs will not be required to respond appropriately with a reciprocal trace headers.