indexing
Per-run counters for the background metadata runtimes.
A cold indexing pass takes hours, and the interesting question is always which
part of it the time went to: walking, computing content keys, parsing vendor
headers, or writing chunks to the cache. IndexingStats accumulates those
figures for one run and emits them as telemetry — one IndexingProgressEvent
per persisted chunk, and one IndexingSummaryEvent when the run ends.
Module
Functions
report_datasource_root_changed
def report_datasource_root_changed( *, task_hash: str, dataset_identifier: str | None, previous_root: str, new_root: str, other_roots: int, sample_size: int, comparable: int, matches: int, verdict: str, file_id_compared: bool,) ‑> None:Send a DatasourceRootChangedEvent at WARNING. Never raises.
Arguments
task_hash: The(pod, datasource)task hash.dataset_identifier:"{pod_name}/{datasource_name}".previous_root: The share or drive of the root last indexed.new_root: The share or drive of the root this walk uses.other_roots: Further distinct roots still stored for the datasource.sample_size: Stored files sampled under the previous root.comparable: Sampled files that could be checked under the new root.matches: Comparable files that are the same file under the new root.verdict:"same_server","different"or"unknown".file_id_compared: Whether any sample was compared by file ID.
report_metadata_sweep_abandoned
def report_metadata_sweep_abandoned( *, task_hash: str, run_type: str, attempts: int, attempts_allowed: int, last_status: str | None, dead_flow_run_id: str | None,) ‑> None:Send a MetadataSweepAbandonedEvent at ERROR. Never raises.
Arguments
task_hash: The(pod, datasource)task hash.run_type:"file_metadata"or"scan_metadata".attempts: Attempts made, read from the dead run's retry tag.attempts_allowed: The length of the retry ladder.last_status: How the last attempt ended.dead_flow_run_id: The last attempt's flow run.
report_scan_submitted_by_index
def report_scan_submitted_by_index( *, task_hash: str, index_run_id: str | None, submitted: bool, scan_flow_run_id: str | None = None, skip_reason: str | None = None,) ‑> None:Send a ScanSubmittedByIndexEvent. Never raises.
Sent at WARNING when the submission failed, at INFO otherwise.
Arguments
task_hash: The(pod, datasource)task hash.index_run_id: The index pass's bookkeeping run id.submitted: Whether a scan run was submitted.scan_flow_run_id: The submitted scan's flow run, when one was.skip_reason: Why none was submitted.
Global variables
SCAN_SUBMIT_FAILED-skip_reasonof aScanSubmittedByIndexEventwhose submission raised.
Classes
IndexingStats
class IndexingStats( run_type: str, task_hash: str, dataset_identifier: str | None = None, files_seen: int = 0, files_keyed: int = 0, files_reused: int = 0, files_unchanged: int = 0, bytes_read: int = 0, rows_written: int = 0, key_seconds: float = 0.0, parse_seconds: float = 0.0, flush_seconds: float = 0.0, io_concurrency: int | None = None, paths_skipped: int = 0, transient_failures: int = 0, root_probes: int = 0, root_probe_seconds: float = 0.0, files_pruned: int = 0, files_newly_missed: int = 0, files_awaiting_prune: int = 0, link_targets_unreachable: int = 0, link_targets_vanished: int = 0, cancel_reason: str | None = None, lease_loss_cause: str | None = None, last_heartbeat_sent_at: str | None = None, last_heartbeat_received_at: str | None = None, stop_reason: str | None = None, lock_wait_seconds: float | None = None,):Mutable counters for one metadata runtime run.
The run's flow body threads this into the tasks that do the work; each
reports what it did (record_key, record_reuse, record_unchanged,
record_parse, record_flush) and emit_summary closes the run out.
Every emission is swallowed on failure — telemetry must not break an
indexing pass.
Variables
-
bytes_read : int
-
cancel_reason : str | None
-
dataset_identifier : str | None
elapsed_seconds : float- Wall-clock seconds since these counters were created.
-
files_awaiting_prune : int
-
files_keyed : int
-
files_newly_missed : int
files_per_second : float- Files seen per second so far, or0.0before any time has passed.
-
files_pruned : int
-
files_reused : int
-
files_seen : int
-
files_unchanged : int
-
flush_seconds : float
-
io_concurrency : int | None
-
key_seconds : float
-
last_heartbeat_received_at : str | None
-
last_heartbeat_sent_at : str | None
-
lease_loss_cause : str | None
-
link_targets_unreachable : int
-
link_targets_vanished : int
-
lock_wait_seconds : float | None
-
parse_seconds : float
-
paths_skipped : int
-
process_read_bytes : int | None- Bytes this process has read since these counters were created.Unlike
bytes_read, which sums the sizes of the files handled, this is what the OS counted. It is process-wide, so runs sharing a process mix, and on Windows it includes network I/O.Nonewhere the OS has no counter (macOS).
-
root_probe_seconds : float
-
root_probes : int
-
rows_written : int
-
run_type : str
-
stop_reason : str | None
-
task_hash : str
-
transient_failures : int
Methods
emit_summary
def emit_summary(self, status: str, error: BaseException | None = None) ‑> None:Emit the run's totals.
Sent at ERROR level for a failed run, carrying error's type and stack
frames, so a failed pass does not read as a healthy one.
Arguments
status: The run's bookkeeping status ("success","skipped","partial"or"error").error: The exception that failed the run, if any.
record_flush
def record_flush(self, *, rows: int, seconds: float) ‑> None:Record one persisted chunk and emit a progress event.
Arguments
rows: Rows the flush wrote.seconds: Time the flush took.
record_key
def record_key(self, *, size_bytes: int, seconds: float) ‑> None:Record a file whose content key was computed.
Arguments
size_bytes: Bytes read to compute the key.seconds: Time the key computation took.
record_parse
def record_parse(self, seconds: float, *, size_bytes: int = 0) ‑> None:Record one file whose vendor headers were parsed.
file_metadata counts a file via record_key / record_reuse and
scan_metadata counts it here, so files_seen is one file per run
either way.
Arguments
seconds: Time the parse took.size_bytes: Size of the parsed file, counted towardsbytes_read— the parse reads most of the file in practice.
record_reuse
def record_reuse(self) ‑> None:Record a file whose stored content key was reused unchanged.
record_unchanged
def record_unchanged(self) ‑> None:Record a file skipped because its stored row still describes it.
No content key is computed and no row is written for it.
record_unkeyed
def record_unkeyed(self) ‑> None:Record a file indexed without computing a content key.
Hashing is optional (settings.file_hashing_enabled) and off by
default. With it off no key is computed and no bytes are read, so the
file counts as seen but as neither keyed nor reused — counting it as
keyed would report the whole dataset as bytes read by a pass that read
none of it.
timer_totals
def timer_totals(self) ‑> dict[str, bitfount.telemetry.logs.models.TimerTotals] | None:What each tracked timer did since tracking began, or None if none is.
Keyed by timer name with dots as underscores, which Datadog would
otherwise read as nesting. The timers are process-wide, so runs sharing
a process mix, as with process_read_bytes.
track_timers
def track_timers(self, names: Iterable[str]) ‑> None:Report what the named timers do from now on, in every event.
Called with the datasource's indexing_timer_names once the run knows
its datasource, before the work they time begins.
Arguments
names: Timer names, as given totiming_utils.get_timer.