feat: add tusk drift query CLI commands for span querying#214
Merged
sohankshirsagar merged 4 commits intomainfrom Apr 1, 2026
Merged
feat: add tusk drift query CLI commands for span querying#214sohankshirsagar merged 4 commits intomainfrom
tusk drift query CLI commands for span querying#214sohankshirsagar merged 4 commits intomainfrom
Conversation
Tusk Drift enables you to record and replay traces from real traffic. These recorded traces make up an API test suite, which you can run locally or in CI/CD pipelines. ## Concepts overview A **trace** represents the full path of an inbound request in your application. A **span** represents a unit of work or operation in a trace. We capture all outbound requests made from your service (e.g., database calls, HTTP requests) in the path of a trace. Further reading: <https://opentelemetry.io/docs/concepts/signals/traces/> ## Setup Setup involves creating a `.tusk/config.yaml` file in the directory of the service you wish to test. This lets Tusk know how to start your service and wait for it to be ready during replay mode. You can run `tusk drift setup` to start an AI agent to automatically set up your service for Tusk Drift or `tusk drift init` to start a configuration wizard. ## Test workflow 1. Instrument your app with the Tusk SDK. 1. Once your app is up and ready, send traffic to it. - Tusk will record traces in `.tusk/traces`. - Shut down your app when you're done. 1. Run `tusk drift run` to run these traces locally. 1. Set up a workflow to run tests in your CI/CD pipeline. Usage: tusk drift [command] Available Commands: init Set up a new service with Tusk init-cloud Initialize Tusk Drift Cloud for this service list List available traces for replay run Run API tests setup AI-powered setup wizard for Tusk Drift Flags: --config string config file (default is .tusk/config.yaml) -h, --help help for drift Global Flags: --debug debug output -v, --version show version and exit Use "tusk drift [command] --help" for more information about a command. CLI commands for span querying
Contributor
There was a problem hiding this comment.
1 issue found across 9 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="cmd/drift_query_aggregate.go">
<violation number="1" location="cmd/drift_query_aggregate.go:40">
P2: `--limit` is documented as 1-100 but is never validated before sending the API request.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
1 task
jy-tan
approved these changes
Apr 1, 2026
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.
Summary
Adds 6 new CLI commands under
tusk drift querythat expose the same span querying capabilities as the https://github.com/Use-Tusk/drift-mcp, allowing users to search, analyze, and debug recorded API traffic directly fromthe CLI. This enables a skill-driven workflow where users can install the skill (will be available on https://github.com/Use-Tusk/tusk-skills shortly after this pr is merged) instead of configuring an MCP server.
Changes
internal/driftquery/types.go— Go structs for filter types (StringFilter, NumberFilter, BooleanFilter, SpanWhereClause, JsonbFilter) and 6 tool input types, matching the MCP'stypes.tswith camelCase JSON tags
internal/api/drift_query.go— 6 newTuskClientmethods (QueryDriftSpans,GetDriftSchema,ListDriftDistinctValues,AggregateDriftSpans,GetDriftTrace,GetDriftSpansByIds)using
makeJSONRequestWithBody, returningjson.RawMessageto avoid maintaining response structscmd/drift_query.go— Parenttusk drift querycommand + shared helpers:setupDriftQueryCloud,resolveQueryServiceID(flag >TUSK_DRIFT_SERVICE_IDenv > config),buildWhereFromFlags, JSON parsing helpers,splitCommacmd/drift_query_spans.go— Search spans with convenience flags (--name,--package-name,--trace-id,--min-duration, etc.) and advanced JSON flags (--where,--jsonb-filters)cmd/drift_query_distinct.go— List unique field values (--fieldrequired)cmd/drift_query_aggregate.go— Aggregate metrics (--metricsrequired,--group-by,--time-bucket)cmd/drift_query_trace.go— Get full trace tree by trace ID (positional arg)cmd/drift_query_schema.go— Get schema info and example payloadscmd/drift_query_spans_by_ids.go— Fetch spans by ID (--idsrequired)Design decisions
json.RawMessagefor responses — Commands print backend JSON directly viaprintJSONrather than parsing into typed Go structs. This avoids duplicated maintenance when backend responseshapes change.
TUSK_DRIFT_SERVICE_IDenv var support (new to CLI, matches MCP behavior) alongside--service-idflag and.tusk/config.yaml.--name,--package-nameetc. Complex nested filters (AND/OR, JSONB paths) use--whereand--jsonb-filtersas JSON strings, which is fine since the primary consumer is an AI agent via the skill.