Advanced Transformer use cases
Use the Advanced Transformer to access metadata, state, and utility functions through the context object. The following examples show common implementation patterns.
Add traceability information
Attach processing identifiers to downstream events.
Example output:
Capture source file information
Use source metadata for troubleshooting and audit scenarios.
Example output:
Include billing context
Expose subscription and catalog information downstream.
Event deduplication
Use event metadata together with a durable key-value store to ensure an event is processed only once.
This pattern is commonly used when files may be replayed, sources may resend events, or pipelines need exactly-once business processing.
Create an audit record
Build a complete audit envelope around the original event.
Operational logging
Generate troubleshooting logs during processing.
Logs are emitted only when logging is enabled for the operator.
Working with context state
Context state allows scripts to retain information across records.
Running aggregations with context.state
Maintain a running total for each customer.
Shared state across pipelines
Use external state when multiple operators or pipelines need access to the same data.
External state requires Redis configuration on the operator.
Bulk lookup operations
Retrieve multiple records in a single call.
Windowed and accumulator scripts
When processing a collection of events, access metadata by index.
Use this pattern with Advanced Accumulator, window process functions, and scripts that receive event collections.