Skip to main content

Supported Side Effects

There are certain number of side-effects that you can attach to your flow, which execute when a transformer executes like sending telemetry data or sending a discord alert when something goes wrong. These side-effects can also be added globally, which will make them run on every state change, or locally, which will make them run on specific nodes.

Attaching Global Side-Effect

For attaching a Side-Effect globally, you need to add that to the root of logicDef object. Here is an example that adds telemetry side-effect globally, which sends telemetry events on start and end of any node by default.

"logicDef": {
"id": "flowId",
"transformers": [
{
"id": "2",
"type": "HTTP_GET",
"config": {
"url": "https://geoip.samagra.io"
},
"states": {
"onError": "3"
},
},
...
],
// Global Side-Effect
"sideEffects": {
"Telemetry": {
"isGlobal": true,
"host": "TELEMETRY_HOST"
}
}
}

Attaching Local Side-Effect

For attaching a Side-Effect locally (to a specific transformer node), you need to add that to the node object itself. Here is an example which adds two seperate telemetry events on two different nodes.

"logicDef": {
"id": "flowId",
"transformers": [
{
"id": "2",
"type": "HTTP_GET",
"config": {
"url": "https://geoip.samagra.io"
},
"states": {
"onError": "3"
},
"sideEffects": {
// Side-Effect 1
"CustomTelemetry": {
"eventId": "E009",
"host": "TELEMETRY_HOST",
"setters": {
"queryClass": "transformer.metaData.state"
}
},
}
},
{
"id": "3",
"type": "HTTP_GET",
"config": {
"url": "https://geoip.samagra.io"
},
"states": {
"onError": "4"
},
"sideEffects": {
// Side-Effect 2
"sideEffects": {
"Telemetry": {
"isGlobal": true,
"host": "TELEMETRY_HOST"
}
},
}
},
],
}

This flexibility of having individual node level telemetry seems nice, but what if you want to have the same behaviour for multiple nodes, just not "all" nodes. Well its really tedious to write side-effects in each of the nodes, hence there is another way to set side-effects in specific nodes. To set side-effects in specific nodes you need to use attachTo property of a side-effect.

"logicDef": {
"id": "flowId",
"transformers": [
{
"id": "2",
"type": "HTTP_GET",
"config": {
"url": "https://geoip.samagra.io"
},
"states": {
"onError": "3"
},
},
{
"id": "3",
"type": "HTTP_GET",
"config": {
"url": "https://geoip.samagra.io"
},
"states": {
"onError": "4"
},
},
{
"id": "4",
"type": "HTTP_GET",
"config": {
"url": "https://geoip.samagra.io"
},
"states": {
"onError": "5"
},
},
],
"sideEffects": {
"Telemetry": {
// Side-Effect is only applied to 2 and 4 nodes.
"attachTo": [ 2, 4 ],
"host": "TELEMETRY_HOST"
}
},
}

Supported Side-Effects

Here is the list of Side-Effects and how to use them.

CustomTelemetry

A CustomTelemetry event allows you to customize certain configurations of a telemetry event as well as set custom data fields extracted from an XMessage.

Config Parameters

NameTypeRequiredDescription
hostStringYESIf base url of the telemetry service on which telemetry data must be sent.
eventIdStringYESThe eventId of the telemetry event being sent.
attachToArray<string>NOThe nodes on which a side-effect must execute.
isGlobalBooleanNOIf true, a side-effect would execute on all the transformer nodes.
settersRecord<string, string>NOThis field enables custom fields to be set in the telemetry data. The key of each item must be the name of the field to be set and the value of an item indicates the data that must be extracted from an XMessage. See example here.

Example

"CustomTelemetry": {
"eventId": "E009",
"host": "TELEMETRY_HOST",
"setters": {
"queryClass": "transformer.metaData.state"
}
}

Telemetry

A Telemetry side-effect allows you to send data to telemetry, but does not allow any customization of data fields or event ids like CustomTelemetry does.

Config Parameters

NameTypeRequiredDescription
hostStringYESIf base url of the telemetry service on which telemetry data must be sent.
attachToArray<string>NOThe nodes on which a side-effect must execute.
isGlobalBooleanNOIf true, a side-effect would execute on all the transformer nodes.

Example

"Telemetry": {
"host": "TELEMETRY_HOST"
}