adding-new-metadata
Installation
SKILL.md
Adding New Metadata to WindowedValue
This skill provides a comprehensive guide on adding new metadata (e.g., CDC metadata, drain mode flags, OpenTelemetry trace context) to Apache Beam's WindowedValue and ensuring it propagates correctly through the execution engine. Failing to propagate metadata in all necessary places will result in metadata loss during pipeline execution.
1. Extending the Proto Model
When adding new metadata that must cross worker boundaries or be serialized by the Fn API, the proto definitions must be updated.
- Key Files:
model/fn-execution/src/main/proto/org/apache/beam/model/fn_execution/v1/beam_fn_api.proto - Action: Add the new metadata field to the appropriate message (
ElementMetadata). - Note: Add proper documentation in proto. Type of the field can be different from the type in WindowedValue, see OpenTelemetry trace context for example.
2. WindowedValue Interface and Implementations
The WindowedValue is the core container for elements flowing through a Beam pipeline. It holds the value, timestamp, windows, pane info, and any additional metadata.
Core Interface Updates
- Key File:
sdks/java/core/src/main/java/org/apache/beam/sdk/values/WindowedValue.java - Action: Add getter methods for your new metadata.