Skip to content

feat: capture write-time materialization metrics (local engine)#371

Open
Manisha4 wants to merge 2 commits into
masterfrom
feat/EAPC-22385-materialization-metrics-capture
Open

feat: capture write-time materialization metrics (local engine)#371
Manisha4 wants to merge 2 commits into
masterfrom
feat/EAPC-22385-materialization-metrics-capture

Conversation

@Manisha4

@Manisha4 Manisha4 commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Add a write-time metrics capture layer for materialization (EAPC-22385), local compute engine + Cassandra first. Off by default; gated behind the ENABLE_MATERIALIZATION_METRICS env var.

  • MaterializationMetricsAggregator (feast/_materialization_metrics.py): accumulates rows_read_offline, rows_written_online, drop_reasons, fields_written, field_null_counts, and max_event_timestamp/lag_seconds. Invariant: rows_read - rows_written == rows_dropped == sum(drop_reasons).
  • ExecutionContext carries an optional metrics_collector; instantiated in ComputeEngine.get_execution_context only for a MaterializationTask when the env gate is on.
  • Local nodes populate it: LocalSourceReadNode (rows_read), LocalFilterNode (filter drops), LocalDedupNode (dedup drops), LocalOutputNode (rows_written, fields, null counts, freshness). All no-ops when the collector is absent.
  • The online store reaches the aggregator via a ContextVar the output node binds around the write (collecting()), so online_write_batch's signature is unchanged. Cassandra records ttl_expired / ttl_exceeds_max at its TTL skip points, best-effort.
  • Unit tests for the aggregator and the node hooks, incl. the contextvar store-drop seam.

What this PR does / why we need it:

Which issue(s) this PR fixes:

Misc

Manisha4 and others added 2 commits July 1, 2026 10:57
Add a write-time metrics capture layer for materialization (EAPC-22385),
local compute engine + Cassandra first. Off by default; gated behind the
ENABLE_MATERIALIZATION_METRICS env var.

- MaterializationMetricsAggregator (feast/_materialization_metrics.py):
  accumulates rows_read_offline, rows_written_online, drop_reasons,
  fields_written, field_null_counts, and max_event_timestamp/lag_seconds.
  Invariant: rows_read - rows_written == rows_dropped == sum(drop_reasons).
- ExecutionContext carries an optional metrics_collector; instantiated in
  ComputeEngine.get_execution_context only for a MaterializationTask when
  the env gate is on.
- Local nodes populate it: LocalSourceReadNode (rows_read), LocalFilterNode
  (filter drops), LocalDedupNode (dedup drops), LocalOutputNode (rows_written,
  fields, null counts, freshness). All no-ops when the collector is absent.
- The online store reaches the aggregator via a ContextVar the output node
  binds around the write (collecting()), so online_write_batch's signature is
  unchanged. Cassandra records ttl_expired / ttl_exceeds_max at its TTL skip
  points, best-effort.
- Unit tests for the aggregator and the node hooks, incl. the contextvar
  store-drop seam.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…olume metrics (EAPC-22385)

Extend the write-time materialization metrics collector to the Spark compute
engine and add the remaining Layer-1 volume metrics.

- Spark path: MaterializationStatsAccumulatorParam merges per-executor stats
  (via the pure, commutative merge_stats) back to the driver; map_in_arrow
  builds a per-partition aggregator bound through collecting() so the online
  store's TTL-skip drops are captured on the executor.
- merge_from_dict folds the accumulator result into the driver-side collector.
- Volume metrics: bytes_written (Arrow nbytes, both engines) and
  distinct_entity_keys (exact via pyarrow group_by on the local engine; left
  unset on Spark to avoid a second DAG-re-executing pass -- HLL follow-up).
- Layer-1 -> job bridge (record_run_result / drain_run_results) so the
  materialization job can drain write-time stats after store.materialize().
- Env-gated (ENABLE_MATERIALIZATION_METRICS), no-op when disabled.

Tests: collector merge/volume/bridge + Spark accumulator path (pyspark-guarded).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant