feat(traces): implement search and aggregate subcommands#65
Draft
jakedgy wants to merge 7 commits intodatadog-labs:mainfrom
Draft
feat(traces): implement search and aggregate subcommands#65jakedgy wants to merge 7 commits intodatadog-labs:mainfrom
jakedgy wants to merge 7 commits intodatadog-labs:mainfrom
Conversation
Resolves the design phase for issue datadog-labs#49. Documents the command interface (search + aggregate), typed API client approach, testing strategy, and follow-up work (time range unification, SpansMetrics CRUD). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Detailed task-by-task plan: skeleton, search, aggregate, tests, docs update, and PR creation. References the design doc. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add tracesCmd with search and aggregate subcommands, flags, and structure tests. RunE functions are stubs that will be implemented in subsequent commits. Closes datadog-labs#49 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Uses typed SpansApi.ListSpans with manual cursor-based pagination. Supports --query, --from, --to, --limit, --sort flags with flexible time parsing. Includes detailed error messages with troubleshooting hints. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Uses typed SpansApi.AggregateSpans with --compute parsing reusing the existing parseComputeString helper. Supports grouping by any span facet via --group-by. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update traces status from placeholder to working. Add search and aggregate subcommands to command index. Update domain categories description. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Replace the placeholder
tracescommand with workingsearchandaggregatesubcommands using the typeddatadogV2.SpansApi.This is a draft — I'm using these subcommands in real investigation workflows to shape the interface before requesting review.
Closes #49
Motivation: Agent-Driven Trace Investigation
The primary use case is AI agents performing structured investigations. The
apmcommand provides the bird's-eye view (services, operations, dependencies), but when an agent needs to drill into why a service is slow or erroring, it needs span-level data:searchandaggregateare the two operations that matter for this workflow. Everything else (SpansMetrics CRUD, etc.) is out of scope — it doesn't serve the investigation use case.What's Here
traces search— find individual spans with auto-pagination (SpansApi.ListSpans)traces aggregate— compute stats over spans (SpansApi.AggregateSpans), reusesparseComputeStringfrom logs--from/--toflexible time parsing,--queryspan syntax,formatter.FormatOutputWhat's Still Being Explored
I have actual work that will exercise these commands, so I'm letting real usage inform what needs to change before this is review-ready:
--limit 50the right default, or do investigation flows need more/fewer spans?--compute/--group-byfeel right in practice, or should it mirror the logs interface more closely?Testing
go test -race ./...🤖 Generated with Claude Code