fix(intake): Do not read unneeded trace input/output for list view#334
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesTrace index root payload removal
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
services/intake/src/nmp/intake/spans/trace_repository.py (1)
266-274:⚠️ Potential issue | 🟠 MajorStop detailed rollups from selecting span payload columns.
_trace_aggregates_sql()callscurrent_spans_sql()without limiting columns, so the generated query includesargMax()forinputandoutputdespite aggregating only trace-level metrics. Pass a lean value-column set to exclude payload columns.Proposed fix
def _trace_aggregates_sql(table: str) -> tuple[str, dict[str, Any]]: @@ FROM { current_spans_sql( table, + value_columns=("status", "attributes_string", "attributes_number", "is_deleted"), extra_where_sql=( "(span_versions.workspace, span_versions.source_format, span_versions.trace_id) IN " "(SELECT workspace, source_format, id FROM page_traces)" ), ) } AS {source_alias} @@ -def current_spans_sql(table: str, *, extra_where_sql: str | None = None) -> str: +def current_spans_sql( + table: str, + *, + extra_where_sql: str | None = None, + value_columns: tuple[str, ...] = _CURRENT_SPAN_VALUE_COLUMNS, +) -> str: @@ *[ f"argMax({source_alias}.{column}, ({source_alias}.event_ts, {source_alias}.is_deleted)) AS {column}" - for column in _CURRENT_SPAN_VALUE_COLUMNS + for column in value_columns ],Add regression assertions in tests:
assert "sumIf" in client.queries[1] assert "groupUniqArrayIf" in client.queries[1] + assert "span_versions.input" not in client.queries[1] + assert "span_versions.output" not in client.queries[1] assert "count() AS span_count" in client.queries[1]Verify the rendered detailed query excludes
input/outputcolumn selections.Also applies to: 324-331
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@services/intake/src/nmp/intake/spans/trace_repository.py` around lines 266 - 274, The `_trace_aggregates_sql()` function calls `current_spans_sql()` without specifying which columns to select, causing unnecessary payload column aggregations like `argMax()` for `input` and `output` columns even though only trace-level metrics are needed. Pass a lean set of value columns to the `current_spans_sql()` call that excludes the payload columns `input` and `output`. This issue applies to two locations: the main call site around lines 266-274 (in the outer FROM clause of the detailed trace aggregates query) and the second location at lines 324-331. Modify both calls to `current_spans_sql()` to include a column parameter that specifies only the necessary trace-level metric columns.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@services/intake/src/nmp/intake/spans/trace_repository.py`:
- Around line 266-274: The `_trace_aggregates_sql()` function calls
`current_spans_sql()` without specifying which columns to select, causing
unnecessary payload column aggregations like `argMax()` for `input` and `output`
columns even though only trace-level metrics are needed. Pass a lean set of
value columns to the `current_spans_sql()` call that excludes the payload
columns `input` and `output`. This issue applies to two locations: the main call
site around lines 266-274 (in the outer FROM clause of the detailed trace
aggregates query) and the second location at lines 324-331. Modify both calls to
`current_spans_sql()` to include a column parameter that specifies only the
necessary trace-level metric columns.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: e356bdbe-5086-40af-890d-3bfa2aecdf5f
📒 Files selected for processing (2)
services/intake/src/nmp/intake/spans/trace_repository.pyservices/intake/tests/test_traces_clickhouse_repository.py
|
60e0867 to
53f99a4
Compare
Signed-off-by: Brian Newsom <[email protected]>
53f99a4 to
f16279d
Compare
Summary by CodeRabbit
input/outputpayload fields.input/outputfrom trace rollup/value aggregation so only the supported aggregate fields are returned.Nonevalues for omitted payload fields.