Worker Module Functions
Functions for managing workers, channels, and registered functions.engine::channels::create
Create a streaming channel pair for real-time communication.number
Channel buffer size (default: 64, max: 1024)
StreamChannelRef
Writer channel reference for sending data
StreamChannelRef
Reader channel reference for receiving data
engine::functions::list
List all registered functions in the engine.boolean
default:false
Include internal engine functions (engine.* prefix)
array
Array of function information objects
engine::workers::list
List all connected workers with metrics.string
Filter by specific worker ID
array
Array of worker information objects
number
Query timestamp (milliseconds)
engine::triggers::list
List all registered triggers.boolean
default:false
Include internal engine triggers
array
Array of trigger information objects
engine::workers::register
Register or update worker metadata.string
required
Worker ID (automatically injected)
string
Runtime environment (e.g., “node”, “rust”, “python”)
string
Worker version
string
Worker name
string
Operating system information
object
Telemetry metadata
boolean
Registration success status
KV Server Functions
Key-value storage functions for persistent state.kv_server::get
Get a value by key from the KV store.string
required
Index name (namespace)
string
required
Key to retrieve
any
The stored value, or null if not found
kv_server::set
Set a value by key in the KV store.string
required
Index name (namespace)
string
required
Key to set
any
required
Value to store (any JSON-serializable data)
string
The key that was set
any
The value that was stored
boolean
Whether this was a new key (true) or update (false)
kv_server::delete
Delete a value by key from the KV store.string
required
Index name (namespace)
string
required
Key to delete
boolean
Whether the key was deleted
any
The previous value, if it existed
kv_server::update
Update a value with atomic operations.string
required
Index name (namespace)
string
required
Key to update
array
required
Array of update operations
any
The value before the update
any
The value after the update
Set { path, value }- Set a field at the specified pathMerge { path, value }- Merge an object with the existing valueIncrement { path, by }- Add a numeric value to a fieldDecrement { path, by }- Subtract a numeric value from a fieldRemove { path }- Remove a field at the specified path
kv_server::list
List all values in an index.string
required
Index name (namespace)
array
Array of all values in the index
kv_server::list_keys_with_prefix
List all keys with a specific prefix.string
required
Key prefix to filter by
array
Array of matching keys
Observability Functions
Functions for logging, tracing, metrics, and monitoring.Logging Functions
OTEL-native logging functions with structured data support.engine::log::info
Log an informational message.string
required
Log message
object
Structured data/attributes
string
Trace ID for correlation
string
Span ID for correlation
string
Service name (defaults to function name)
engine::log::warn
Log a warning message. Parameters are identical toengine::log::info.
engine::log::error
Log an error message. Parameters are identical toengine::log::info.
engine::log::debug
Log a debug message. Parameters are identical toengine::log::info.
engine::log::trace
Log a trace-level message. Parameters are identical toengine::log::info.
Baggage Functions
Access and manage OpenTelemetry baggage for context propagation.engine::baggage::get
Get a baggage item value from the current context.string
required
Baggage key to retrieve
string
Baggage value, or null if not found
engine::baggage::set
Set a baggage item value.Baggage in OpenTelemetry is immutable. This function creates a new context but cannot propagate it back to the caller. For real baggage propagation, use SDK-level baggage headers.
string
required
Baggage key to set
string
required
Baggage value
engine::baggage::get_all
Get all baggage items from the current context.object
Object with all baggage key-value pairs
Traces Functions
Query and manage distributed traces.Trace storage is only available when the OTEL exporter is set to
memory or both in configuration.engine::traces::list
List stored traces with filtering and pagination.string
Filter by specific trace ID
number
default:0
Pagination offset
number
default:100
Maximum number of spans to return
string
Filter by service name (substring match)
string
Filter by span name (substring match)
string
Filter by status (substring match)
number
Minimum span duration in milliseconds
number
Maximum span duration in milliseconds
number
Start time in Unix timestamp milliseconds
number
End time in Unix timestamp milliseconds
string
default:"start_time"
Sort field: “duration”, “start_time”, or “name”
string
default:"asc"
Sort order: “asc” or “desc”
array
Filter by attributes (array of [key, value] pairs)
boolean
default:false
Include internal engine traces
array
Array of span objects
number
Total number of matching spans
number
Current offset
number
Current limit
engine::traces::tree
Get trace tree with nested children for a specific trace.string
required
Trace ID to build the tree for
array
Array of root span tree nodes with nested children
engine::traces::clear
Clear all stored traces from memory.boolean
Clear operation success status
Metrics Functions
Query engine and SDK metrics.engine::metrics::list
List current metrics values.number
Start time in Unix timestamp milliseconds
number
End time in Unix timestamp milliseconds
string
Filter by metric name
number
Aggregate interval in seconds
object
Engine internal metrics
array
SDK-recorded metrics
array
Time-aggregated metrics (if aggregate_interval specified)
number
Query timestamp
engine::rollups::list
Get pre-aggregated metrics rollups.number
Start time in Unix timestamp milliseconds (default: 1 hour ago)
number
End time in Unix timestamp milliseconds (default: now)
number
default:0
Rollup level: 0 = 1 minute, 1 = 5 minutes, 2 = 1 hour
string
Filter by metric name
array
Array of metric rollups
array
Array of histogram rollups
number
Rollup level used
Logs Functions
Query and manage stored logs.engine::logs::list
List stored OTEL logs with filtering.string
Filter by trace ID
string
Filter by span ID
number
Minimum severity number (1-24, higher = more severe)
string
Filter by severity text (e.g., “ERROR”, “WARN”, “INFO”)
number
Start time in Unix timestamp milliseconds
number
End time in Unix timestamp milliseconds
number
Pagination offset
number
Maximum number of logs to return
array
Array of log entries
number
Total number of matching logs
engine::logs::clear
Clear all stored OTEL logs.boolean
Clear operation success status
Health and Diagnostics
engine::health::check
Check system health status.string
Overall health status
object
Health status of individual components
number
Check timestamp
string
Engine version
engine::sampling::rules
Get active sampling rules configuration.object
Trace sampling configuration
object
Log sampling configuration
Alerts Functions
Manage and query alert states.engine::alerts::list
List current alert states.array
Array of alert state objects
number
Number of currently firing alerts
engine::alerts::evaluate
Manually trigger alert evaluation.boolean
Whether evaluation occurred
array
Array of alerts that triggered
Error Handling
All built-in functions return errors in a consistent format:memory_exporter_not_enabled- Trace/log storage not availableserialization_error- Failed to serialize response datainvalid_input- Invalid input parameters
Best Practices
Use Internal Filtering
Set
include_internal: false when querying functions, triggers, or traces to exclude engine internals from results.Batch KV Operations
Use
kv_server::update with multiple operations instead of multiple set calls for better performance.Monitor Memory Usage
When using memory exporters, regularly clear old traces and logs to prevent memory growth.
Use Structured Logging
Always include the
data parameter with structured attributes in log functions for better queryability.Related Resources
Modules Overview
Learn about iii framework modules
Observability
Configure OTEL and monitoring
State Management
Using the KV store for state
Custom Modules
Creating custom modules