Repository navigation
PR #62 follow-up 15: apply exact time bounds in get_trace_activity - #72
Merged
Merged
Conversation
The generic query API rounds startTime/endTime down to the minute, so a sub-minute trace activity range collapsed to an empty window, and ranges crossing a minute boundary included rows outside the requested bounds. Resolve the bounds once, reject start >= end, put exact half-open predicates in the SQL, widen the transport envelope to whole minutes (as list_log_errors does), size buckets from the exact range and align DATE_BIN to the requested start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… fix/pr62-15-trace-activity-exact-range # Conflicts: # docs/tool-api.md # src/tool_executor.rs
… fix/pr62-15-trace-activity-exact-range
…ivity-exact-range # Conflicts: # docs/tool-api.md # src/tool_executor.rs
…ivity-exact-range
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up item 15 from the PR #62 review (upstream-inherited code from parseablehq/parseable 32979cb, "update: tool catalog (parseablehq#1831)").
Problem
get_trace_activitypassed the caller's rawstartTime/endTimetoquery_internal, which builds its scan range withTimeRange::parse_human_timeand rounds both bounds down to the minute. The generated SQL had no time predicate of its own, so:10:30:10Z–10:30:50Zcollapsed to the empty window[10:30:00, 10:30:00)and returned no rows;[floor(start), floor(end)), which included rows beforestartTimeand dropped rows betweenfloor(endTime)andendTime;time_bucket_intervalsized buckets from the rounded range (falling back to 3600s on a parse error), andDATE_BINwas aligned to the epoch, so the first and last buckets were partial.Fix
This follows the fork's
list_log_errorsapproach (85358df,log_error_query_request):trace_activity_rangeresolvesstartTime/endTimeonce (relative expressions share onenow) and rejectsstart >= endand unparsable bounds.trace_activity_queryadds exact half-open predicates (time >= start AND time < end) to the SQL and alignsDATE_BINto the requested start.trace_activity_requestsends a minute-widened transport envelope,[floor(start), floor(end) + 1m), using checked arithmetic, so the generic query API's rounding can no longer drop rows. It validates the SQL withvalidate_tool_sqland keeps the query's ownLIMIT 501, which item 14 (PR #62 follow-up 14: signal get_trace_activity truncation at 500 rows #71) uses to detect truncation.time_bucket_intervalsizes buckets from the exact range.docs/tool-api.mdnow documents the exact half-open bounds, thestart < endrequirement, the start-aligned buckets, and the fact that the returned SQL embeds the exact bounds.Tests
trace_activity_subminute_range_returns_exact_rowsruns the tool's request through DataFusion. It first applies the query API's minute-rounded transport filter to the fixture, then the generated SQL. It covers a sub-minute range, the inclusive start and exclusive end, and a range crossing a minute boundary, and checks bucket labels aligned to the start.trace_activity_request_validates_exact_ranges_and_widens_transportcovers resolving relative bounds once, preserving microsecond precision in the SQL, the transport envelope, and rejecting empty, inverted and invalid ranges.cargo test --lib tool_passes (40 tests),cargo clippy -- -D warningsis clean, andcargo clippy --all-targetsadds no warnings in touched files.Upstream fidelity
The diff is confined to the trace activity helpers in
src/tool_executor.rs, their tests, and the docs section.trace_activity_queryandtime_bucket_intervalgain arangeparameter, and there are two new small helpers. The bug exists upstream too, and an upstream proposal is drafted separately; nothing has been filed upstream.Stacking
This was opened stacked on #62. #62 has merged, so this PR now targets
mainand hasmainmerged in, including item 14 (#71), item 17 (#73) and item 20 (#69). Item 14's truncation test now passes an explicit range.🤖 Generated with Claude Code