Jido.Messaging.Signal.Ext.CorrelationId (Jido Messaging v1.0.0)

Copy Markdown View Source

Signal extension for message correlation tracking in Jido.Messaging.

This extension provides a simple correlation_id field for tracing related messages through the messaging pipeline. It's used to link:

  • Inbound messages to their processing events
  • Agent triggers to their responses
  • Delivery attempts to their outcomes

Usage

The correlation ID is automatically populated by Jido.Messaging.Signal functions:

# Automatically added when emitting signals
Jido.Messaging.Signal.emit_received(message, context)

# The signal will have:
# signal.extensions["correlationid"] == %{"id" => "msg_abc123"}

Relationship to Jido.Signal.Ext.Trace

This extension is complementary to the trace extension (correlation namespace):

  • Trace extension: Full distributed tracing with trace_id, span_id, parent_span_id
  • CorrelationId extension: Simple message-level correlation for messaging workflows

Use trace extension for cross-service distributed tracing. Use this extension for message-level correlation within the messaging domain.

Registration

Call ensure_registered/0 at application startup to register this extension:

Jido.Messaging.Signal.Ext.CorrelationId.ensure_registered()

Summary

Functions

Ensures the extension is registered with the signal registry.

Validates data according to this extension's schema.

Functions

ensure_registered()

@spec ensure_registered() :: :ok

Ensures the extension is registered with the signal registry.

This should be called at application startup or before using signals with correlation IDs. Safe to call multiple times.

validate_data(data)

@spec validate_data(term()) :: {:ok, term()} | {:error, String.t()}

Validates data according to this extension's schema.

Parameters

  • data - The data to validate

Returns

{:ok, validated_data} if valid, {:error, reason} otherwise

Examples

iex> MyExt.validate_data(%{user_id: "123"})
{:ok, %{user_id: "123"}}

iex> MyExt.validate_data(%{})
{:error, "required :user_id option not found"}