-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
Description
Search before asking
- I had searched in the feature and found no similar feature requirement.
Description
Currently, SeaTunnel Metrics are generally global. We cannot distinguish metrics for a specific subset of data (e.g., sampled traffic, heartbeat packets) without aggressively modifying the connector/transform code to add tags manually.
This proposal aims to introduce a System-Level Traffic Dyeing (Sampling) mechanism. It allows:
- Marking specific
SeaTunnelRows as "Sampled" or "Dyed" at the Source. - Propagating this "Color" context implicitly throughout the execution engine (Source -> Transform -> Sink).
- Automatically routing metrics to different counters (e.g.,
sink_write_countvssink_write_count_sampled) based on the context, without changing existing Connector code.
Proposed Solution / Architecture:
- Data Protocol: Add a
long flagsfield toSeaTunnelRow(Core Data Structure). This uses a bitmask to carry system signals (e.g.,IS_SAMPLED,IS_HEARTBEAT) with minimal serialization overhead compared to the existingoptionsMap. - Context Propagation: Introduce
MetricTraceContext(based onThreadLocal) inseatunnel-engine.- When
SeaTunnelSourceCollectorreceives a row, it checks theflagsand sets theMetricTraceContext. - The context is cleared after the row is processed to ensure safety.
- For async operations, the context must be captured and replayed.
- When
- Metrics Integration: Enhance
MetricsContext(orAbstractMetricsContext) to support "Context-Aware" or "Routing" metrics.- The Metric object (e.g., Counter) acts as a proxy.
- It checks
MetricTraceContexton every update (inc()) and routes the value to the appropriate underlying counter (e.g., standard vs. sampled).
Usage Scenario
- Sampling Observation: In high-throughput scenarios (e.g., 1M QPS), calculating precise latency/success-rate for every record is expensive. Users can configure the Source to "sample" 1% of traffic (set the flag). The Metrics system will then automatically track metrics for this 1% separately, providing health visibility with low overhead.
- Heartbeat Monitoring: Distinguish "Heartbeat" rows (synthetic data for keep-alive) from actual business data in metrics.
- Trace/Debug: "Dye" specific rows to trace their flow and performance through the pipeline without mixing them with normal traffic stats.
Related issues
None.
Are you willing to submit a PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable