Skip to content

feature: per-record request ID logging for Feature Store ingestion - #6576

Draft
grraman wants to merge 2 commits into
aws:masterfrom
grraman:feature-store-write-audit
Draft

grraman wants to merge 2 commits into
aws:masterfrom
grraman:feature-store-write-audit

Conversation

@grraman

@grraman grraman commented Nov 10, 2026

Copy link
Copy Markdown

feature: per-record request ID logging for Feature Store ingestion

Issue

Customers who ingest with ingest_dataframe / IngestionManagerPandas can't tell which AWS request wrote a given record. When a record shows up in the online store but not the offline store, Feature Store support needs the PutRecord or BatchWriteRecord request ID to investigate. Today the SDK throws the response away (FeatureGroup.put_record returns None, BatchWriteRecordResponse drops ResponseMetadata), and the ingestion error logs only show the exception text.

Description of changes

This adds opt-in write audit logging, off by default. When it's on, each record of each PutRecord or BatchWriteRecord HTTP attempt gets one JSON line on the sagemaker.mlops.feature_store.write_audit logger at INFO level. Each line holds the record identifier, event time, AWS request ID, HTTP status, the per-entry outcome and client-side timestamps. Retried attempts each get their own line with their own request ID.

Surface Change
ingest_dataframe(..., enable_write_audit=None) Reads the record identifier and event time feature names from the Feature Group it already describes. When None, the SAGEMAKER_FEATURE_STORE_WRITE_AUDIT environment variable decides.
IngestionManagerPandas(write_audit_config=None) New last field. Audit is set up in the single-process path and inside each worker process.
WriteAuditConfig New public config class, exported from sagemaker.mlops.feature_store.
New write_audit.py Registers handlers on the sagemaker-featurestore-runtime client that sagemaker-core caches, using only the documented botocore events provide-client-params, before-send and needs-retry. The handlers always return None and never raise.
Existing failure logs _ingest_row and the BatchWriteRecord failure path add the request ID when the error carries one. This is on for everyone.
Telemetry IngestionManagerPandas.run reports x-hasWriteAuditConfig.
Docs New "Tracing ingested records to AWS request IDs" section in docs/ml_ops/index.rst.

Only the record identifier and event time are logged, no other feature values. The docs note that record identifiers can be sensitive.

BatchWriteRecord Errors and UnprocessedEntries are matched back to entries by their full record content. If a reported failure matches no entry, entries that would otherwise be accepted are logged as unknown, so a failed record is never reported as accepted.

Usage:

import logging
from sagemaker.mlops.feature_store import ingest_dataframe

logging.getLogger("sagemaker.mlops.feature_store.write_audit").setLevel(logging.INFO)
ingest_dataframe("my-fg", df, max_workers=4, use_batch_write_record=True, enable_write_audit=True)

Known limits, all documented:

  • Records that fail before any request is sent (parameter validation, missing credentials) get no audit line. The existing error log still reports the row.
  • Writes still running after an ingestion timeout aren't audited.
  • If sagemaker-core's client cache is reset mid-ingestion, writes through the new client aren't audited.

Backwards compatibility

All changes are additive. New arguments are added at the end of ingest_dataframe and IngestionManagerPandas, and the existing signature test asserts the full parameter order. With the feature off there are no extra clients, no handler registration and no import-time side effects. The only change on default paths is the request ID suffix on existing error log lines.

Testing done

  • 69 new unit tests in test_write_audit.py, test_ingestion_manager_pandas.py and test_feature_utils.py. All 458 Feature Store unit tests pass. The new tests include end-to-end runs of the real IngestionManagerPandas and botocore against a loopback fake endpoint, covering PutRecord, BatchWriteRecord with a retried 500, partial Errors/UnprocessedEntries, and threaded and multi-process ingestion. They check that every record maps to the request that carried it.
  • Test isolation: the tests pass with AWS_MAX_ATTEMPTS=1 AWS_RETRY_MODE=legacy AWS_PROFILE=nope. test_write_audit.py passed 5 runs in a row.
  • write_audit.py has 100% line coverage.
  • Lint: black, flake8 and pydocstyle are clean with the repo's pinned versions, and pylint scores the new module 10.00.
  • Integration test: tests/integ/test_feature_store_write_audit.py collects but has not been run against AWS. It needs CI.
  • The multi-process unit tests skip when the start method isn't fork. Multi-process ingestion already fails under spawn because the Pool initializer is a nested function. That's a separate fix.

Merge Checklist

  • I have read the CONTRIBUTING doc
  • I used the commit message format described in CONTRIBUTING
  • I have added unit and integration tests
  • Integration tests pass in CI
  • Docs updated (docs/ml_ops/index.rst)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Add opt-in write audit logging to ingest_dataframe and IngestionManagerPandas so
each ingested record can be traced to the AWS request ID of the PutRecord or
BatchWriteRecord attempt that carried it.

- New sagemaker.mlops.feature_store.write_audit module: registers handlers for
  documented botocore events (provide-client-params, before-send, needs-retry) on
  the featurestore-runtime client cached by sagemaker-core, and logs one JSON line
  per record per HTTP attempt (record identifier, event time, request ID, status,
  per-entry outcome, timestamps) on the sagemaker.mlops.feature_store.write_audit
  logger. No other feature values are logged.
- ingest_dataframe(enable_write_audit=...) derives the record identifier and
  event time names from the Feature Group; SAGEMAKER_FEATURE_STORE_WRITE_AUDIT
  enables it without code changes. Off by default.
- IngestionManagerPandas(write_audit_config=...) sets up auditing in the
  single-process path and in each worker process.
- Existing ingestion failure logs now include the request ID when available.
- Telemetry: IngestionManagerPandas.run reports whether write audit is configured.
- Docs, unit tests and an integration test.
…dit tests

Address the CodeQL HTTP Response Splitting alert on the loopback fake Feature Store server. The x-amzn-RequestId header now holds only a server-generated UUID; the mapping to each request's first record is kept server-side for the tests to check.

This branch is waiting to be deployed

1 waiting deployment
manual-approval — 9b8405e6 Waiting Nov 10, 2026 by grraman via wait-for-approval #1933
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.

2 participants