Skip to main content

Event Logging

What is Event Logging?

Event logging is the process of communicating the actions your Connector performs to the SyncHive platform. This may involve simple actions such as receiving data from an external system and preparing it to send to SyncHive, or more complex actions like sending bulk records to an external system and notifying SyncHive once the process is completed.

Why Should You Event Log?

Event logging ensures that the SyncHive platform is aware of the work your Connector is performing. This information provides end-users with accurate and up-to-date visibility of their SyncHive instance, enabling them to monitor activities and resolve issues quickly when they arise.

When Should You Event Log?

We expect Connector developers to provide accurate event logs to SyncHive in the following scenarios:

  1. Receiving data from an external system.
  2. Successfully saving data to an external system in asynchronous scenarios.
  3. Any time an error or pertinent warning occurs.

How to Event Log

There are two primary scenarios to consider when event logging to SyncHive: synchronous processing and asynchronous processing.

Synchronous Processing

In synchronous processing, work is predictably done in sequence from start to finish. Consider the diagrams below for guidance on when to provide event logs.

Inbound Example

Using the example of receiving a webhook from an external system, a Connector is expected to provide an event log when it begins to process a message and if it encounters any errors or warnings while doing so. Since the final step is for a Connector to send a message to SyncHive, an additional event log is not required.

Outbound Example

When receiving a message from SyncHive, a Connector is not required to provide additional event logs. The Connector's response to SyncHive upon receiving a message provides all the necessary information. For more details, see the section on Receiving Messages from SyncHive: Responding to SyncHive.

Asynchronous Processing

In asynchronous processing, a Connector does not immediately process a message received from SyncHive. Instead, it processes the message later. During this time, the Connector must maintain communication with SyncHive and notify it once the message has been processed.

Batch Processing Example

For batch processing multiple messages received individually from SyncHive, a Connector should generate event logs for each message. These logs should indicate whether each message was successfully or unsuccessfully processed.

Event Log Key Concepts

When constructing an event log payload, there are several key concepts to learn:

Lifecycle Stage

A lifecycle stage indicates a particular moment in the SyncHive message lifecycle. When sending an event log, you must specify the corresponding stage within the message lifecycle.

StageKeyNotes
1. Connector collect inbound dataINBOUND_1
2. Connector assemble inbound messageINBOUND_2
3. Connector transfer inbound messageINBOUND_3
4. Platform receive inbound messageINBOUND_4For platform use only
5. Platform store inbound messageINBOUND_5For platform use only
6. Platform generate outbound message(s)OUTBOUND_1For platform use only
7. Connector receive outbound messageOUTBOUND_2
8. Connector assemble outbound dataOUTBOUND_3
9. Connector deliver outbound dataOUTBOUND_4
10. Platform finalize outbound deliveryOUTBOUND_5For platform use only

Event Code

Event codes are alphanumeric representations of the content within an event log. These codes are logically organized into distinct ranges.

Event Code Range

Code RangeCategoryDescription
1000-1999DataRetrieving or storing data
2000-2999LogicBusiness logic or data transformation
3000-3999FilterFiltering messages
4000-4999ContactCommunicating with an external system
5000-5999ExchangeSending or receiving messages
0000Internal Server IssueFallback "catch-all" codes for unexpected issues

Event Code Glossary

Refer to the glossary below to select an appropriate event code when creating your event log. Note that a suffix of the event level is appended to the code.

CodeLevelDescription
1000NINFOData saved
1000WWARNINGCould not save data
1001EERRORData rejected by external system
1001WWARNINGKey data is missing
1002EERRORKey data is missing
1003EERRORDuplicate data ID
1004EERRORInvalid message
1004WWARNINGInvalid message
1005EERRORData is missing
2000NINFOMessage created
2001EERRORBad data received from external system
2002EERRORMessage transformation failed
3000NINFOMessage filtered
3001NINFOMessage skipped
3002EERRORInvalid filter
4000NINFOAuthenticated with SyncHive
4001NINFOAuthenticated with external system
4002EERRORCould not reach SyncHive
4003WWARNINGCould not reach external system
4003EERRORCould not reach external system
4004EERRORAuthentication to SyncHive failed
4004WWARNINGRate Limit Exceeded
4005EERRORAuthentication to external system failed
5000NINFOMessage sent
5001NINFOMessage received
5002EERRORSyncHive rejected the message
5003EERRORData rejected by external system
5003NINFOData polled
5004NINFOData received
5005NINFOData sent
5006WWARNINGUnauthorized
5006EERRORUnauthorized
5007WWARNINGConnector unavailable
5007EERRORConnector unavailable
5008WWARNINGPlatform unavailable
5008EERRORPlatform unavailable
0000EERRORError
0000WWARNINGWarning

Correlation ID

The correlation ID is crucial for maintaining traceability of event logs and messages in SyncHive. The platform uses the correlation ID on messages received for event logging. To ensure that the event logs are linked together, the same correlation ID must be used when event logging in the connector.

See more: Correlation ID.

Writing a Clear and Informative Event Log

When composing the contents of an event log, prioritize clarity and relevance for the end-user. To ensure readability and prompt action, we recommend structuring your event log detail field as follows:

  • What state are we in?
  • How did it happen?
  • What can the end-user do about it?

Example of an Informative Event Log

Failed to send message to ShopifyNZ.

The HTTP API Key was not accepted.

Please provide a valid HTTP API Key to the ShopifyNZ Integration and try again.

Understanding Error Codes

When event logging with an error-level code to SyncHive, the associated message is marked as a terminal failure and will be displayed to end-users in the "Stuck" messages UI. This message must not be processed further by the Connector, so avoid providing any further event logs with new codes for that message.

For example, if a Connector is processing an event from an external system and encounters an issue that it will retry, it should use a warning-level event code. Only when the Connector has stopped retrying and reaches a point of terminal failure should it use an error code.

Event Log API

To send an event log to SyncHive, create a payload according to the schema below and call the following API:

PUThttps://{synchive_url}/data-service/v1/eventLog
Headers
"X-Shopify-Connector-Key": "9XnZr4JmPWTVHuyFBheg",
"limber-connector": "shopify_connector",
"Content-Type": "application/json"
Body
{
"eventCode": "4005E",
"direction": "OUTBOUND",
"lifeCycleStage": "OUTBOUND_4",
"outcome": "FAILED",
"generatedAt": "2024-05-03 17:30:00.895 +1200",
"detail":
"Failed to send message to ShopifyNZ.

The HTTP API Key was not accepted.

Please provide a valid HTTP API Key to the ShopifyNZ Integration and try again.",
"correlationId": "14cac731-6dd7-424c-bfbf-f0be0b07f8cf",
"dataId": {
"@type": "DataReference",
"schemaName": "limber",
"shapeName": "Product",
"externalIdentities": [
{
"integrationKey": "ShopifyNZ",
"externalId": "9217354452632"
}
]
},
"integrationKey": "ShopifyNZ",
"shapeName": "Product",
"mode": "LIVE",
"schemaName": "limber",
"schemaVersion": "2.1.0",
}

Note

Event logs that have a "direction": "INBOUND" may use a "dataId" value that contains either an "externalIdentities" array (pictured above) or an "iri" value (pictured below).

Event logs that have a "direction": "OUTBOUND" must use a "dataId" value that contains an "iri". For example:

"dataId": {
"@type": "DataReference",
"schemaName": "limber",
"shapeName": "Product",
"iri": "https://schema.limbergraph.com/limber/Product#366821d6-a049-46e8-b73a-ea9ee7faea0d"
}

See more ID Resolution: Data References.

Schema
{
eventCode: string,
// Required
// An event code that represents the content of this event log
// Enum (see Event Code documentation below)

direction: string,
// Required
// Direction of data flow. INBOUND for data flowing IN to SyncHive. OUTBOUND for data flowing OUT of SyncHive
// Enum: [ INBOUND, OUTBOUND ]

lifeCycleStage: string,
// Required
// The current stage of processing this event log relates to
// Enum (see Lifecycle Stage documentation below)

outcome: string,
// Required
// The outcome of this event
// Enum: [ WAITING, FILTERED, RETRYING, FAILED, MESSAGE_STORED, MESSAGE_DELIVERED, PROCESSING ]

generatedAt: string,
// Optional
// The date and time with an offset from UTC, represented as a string in the ISO 8601 format
// Example: "2024-05-03 17:30:00.895 +1200"

detail: string,
// Optional
// maxLength: 3000
// Human readable data event log detail. Stored as Markdown

technicalInfo: string,
// Optional
// maxLength: 2000
// A technical message to help end-users resolve issues, typically specific to external systems (e.g. SAP S4/HANA), when more information is needed beyond the "detail" string above

correlationId: string,
// Required
// Correlation ID for related message tracing

dataId: string,
// Required
// A data ID block that associates this event log with data in SyncHive (see Data ID documentation below)

integrationKey: string,
// Required
// Source Integration for the event log

shapeName: string,
// Required
// The type of data this event log relates to (see Shape documentation below)

mode: string,
// Required
// The mode of operation
// Enum: [ LIVE, SANDBOX ]

stream: string,
// Optional
// Advanced: used to let SyncHive know that this event is split into multiple parts.
// Use a unique stream value for each part and ensure that you use the same dataId value for both

schemaName: string,
// Required
// The name of the schema for the event log

schemaVersion: string,
// Optional
// The version of the schema for the event log

customData: JSON,
// Optional
// Custom data to attach to this event log

linkIdentities: string,
// Optional
// Used to link identities in asynchronous scenarios (see Link Identities documentation below)
}

References: Event Code, Lifecycle Stage, Data ID, Shape, Link Identities.