Skip to content

Move query completion logging into onQueryResponse - #1377

Merged
DZakh merged 3 commits into
mainfrom
claude/query-log-contract-events-my220n
Jul 6, 2026
Merged

Move query completion logging into onQueryResponse#1377
DZakh merged 3 commits into
mainfrom
claude/query-log-contract-events-my220n

Conversation

@DZakh

@DZakh DZakh commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

Refactored query completion logging to be emitted per-query within onQueryResponse instead of being accumulated and emitted once per tick in fetchChain. This provides more granular visibility into individual query completions and simplifies the control flow.

Key Changes

  • Moved the "Finished querying" trace log from fetchChain into onQueryResponse, now logged immediately after each query completes with its specific results
  • Removed the per-tick accumulation logic in fetchChain that tracked dispatchedCount, fetchedByPartition, and fetchedCount
  • Each query now logs its own completion details: chainId, partitionId, fromBlock, toBlock, numEvents, and numContractRegisterEvents

Implementation Details

The logging now captures partition-specific metrics directly from the query response, eliminating the need to aggregate results across multiple queries dispatched in a single tick. This makes the log output more immediate and easier to correlate with specific query executions.

https://claude.ai/code/session_01HLzAxQms9kMmEhSaJ2YJ5d

Summary by CodeRabbit

  • Bug Fixes
    • Improved query completion logging to emit a per-query, per-partition trace that includes chain/partition identifiers, block range, and both total and contract register event counts.
    • Removed the prior aggregated “tick-level” completion log, so progress and completion details are more granular and clearer.

claude added 2 commits July 6, 2026 08:32
Previously all queries dispatched in a fetch tick were batched into a
single "Finished querying" log keyed by partition. Log per query
instead, and include the count of events that triggered contract
registration.
Reuse the itemsWithContractRegister count already computed there
instead of re-scanning parsedQueueItems in fetchChain.
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cb61fbe5-3108-4b21-a14e-e2c47a0a3be9

📥 Commits

Reviewing files that changed from the base of the PR and between db8ae9f and 2382923.

📒 Files selected for processing (1)
  • packages/envio/src/ChainFetching.res
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/envio/src/ChainFetching.res

📝 Walkthrough

Walkthrough

onQueryResponse now emits a per-query "Finished querying" trace with partition, block-range, and event-count details. fetchChain no longer aggregates dispatched query completions across a tick or emits one combined completion trace.

Changes

Query Completion Logging

Layer / File(s) Summary
Per-partition trace log
packages/envio/src/ChainFetching.res
Adds a per-partition "Finished querying" trace log in onQueryResponse with chainId, partitionId, block range, and event counts.
Remove tick aggregation
packages/envio/src/ChainFetching.res
Removes the tick-level query completion counters, per-partition completion tracking, and the combined end-of-tick completion trace from fetchChain.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main refactor: moving query completion logging into onQueryResponse.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/envio/src/ChainFetching.res (1)

207-215: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Verify the rollback path still emits a per-query trace.

This log only runs in the NoReorg branch, so queries that detect a reorg no longer appear in the new per-query completion telemetry. If that’s unintended, move the trace before the rollback switch or duplicate it in the reorg branch.

🤖 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 `@packages/envio/src/ChainFetching.res` around lines 207 - 215, The per-query
completion trace in ChainFetching.res only runs in the NoReorg path, so
reorg-detecting queries miss the telemetry. Update the query flow around the
Logging.trace call in the query completion logic so that every query emits this
trace, either by moving it before the rollback branch or by duplicating the same
trace in the reorg path, keeping the existing fields like chainId, partitionId,
fromBlock, and toBlock consistent.
🤖 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.

Nitpick comments:
In `@packages/envio/src/ChainFetching.res`:
- Around line 207-215: The per-query completion trace in ChainFetching.res only
runs in the NoReorg path, so reorg-detecting queries miss the telemetry. Update
the query flow around the Logging.trace call in the query completion logic so
that every query emits this trace, either by moving it before the rollback
branch or by duplicating the same trace in the reorg path, keeping the existing
fields like chainId, partitionId, fromBlock, and toBlock consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bb7d3989-843f-49f0-a30f-856ddaf4223f

📥 Commits

Reviewing files that changed from the base of the PR and between 44d7349 and db8ae9f.

📒 Files selected for processing (1)
  • packages/envio/src/ChainFetching.res

CodeRabbit flagged that the "Finished querying" trace only fired on
the no-reorg path, silently dropping telemetry for queries that
trigger a reorg rollback. Compute the log before the reorg branch so
every non-stale query response is captured.
@DZakh
DZakh merged commit 5195618 into main Jul 6, 2026
8 checks passed
@DZakh
DZakh deleted the claude/query-log-contract-events-my220n branch July 6, 2026 09:13
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