Skip to content

Dataflow cascade observability: no first-class instrumentation for attributing time across observers #822

Description

@paddymul

Summary

The dataflow cascade (_operation_resultcleaned_processed_result_summary_sd_merged_sd_populate_sd_cache) is the hot path for every state_change. When it's slow — and it often is on xorq, polars on large frames, and pandas with expensive autocleaning — diagnosis today means manually adding time.perf_counter() brackets around individual observers and reading them out of ad-hoc print statements.

A few ad-hoc [cache-timing] log lines have crept into dataflow.py (via the buckaroo.dataflow.cache_timing logger). They're useful but inconsistent: some observers are instrumented, some aren't; the format isn't standardised; there's no per-state-change correlation ID so concurrent state changes interleave in the logs; the channel is at INFO level so it floods normal operation.

What would help:

  • A consistent observability layer over the cascade — one log line per observer per fire, with elapsed time, the trait change that triggered it, and a stable correlation key (e.g. the state_change request id or a per-cascade monotonic counter).
  • Optional in-memory metric capture so a test can assert "this state_change ran _summary_sd zero times" without parsing log strings.
  • A way to enable it scoped to a specific session or off by default, on by env / flag.

Bonus: the cascade also exhibits a known double-fire pattern (_populate_sd_cache runs twice per state_change because it observes both summary_sd and operations, set in sequence by _operation_result). Without observability that's hard to even notice.

Scope

Widget AND server — the dataflow code is shared. Both contexts would benefit; server logs are easier to read out of, notebook contexts could surface via a debug panel.

Impact

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions