Skip to content

COBS-1350: Add Insights traces query support - #1162

Merged
kishlay-singh-DO merged 1 commit into
digitalocean:mainfrom
srajputdo:sakshirajput/COBS-1350/traces-query
Oct 12, 2026
Merged

kishlay-singh-DO merged 1 commit into
digitalocean:mainfrom
srajputdo:sakshirajput/COBS-1350/traces-query

Conversation

@srajputdo

@srajputdo srajputdo commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a godo client for the public Insights traces query endpoints, matching the OpenAPI spec merged in digitalocean/openapi#1256.

  • InsightsService.SearchTraces(ctx, region, *TracesSearchRequest) → POST /v2/insights/query/{region}/traces/search
  • InsightsService.GetTrace(ctx, region, traceID, *TraceGetOptions) → GET /v2/insights/query/{region}/traces/{trace_id} with optional from / to lookup window
  • Request/response types mirroring the spec (camelCase tags): TracesSearchRequest, TracesTimeRange / TracesTimeBound, TracesFilterExpression, TracesFilterField, TracesFilterValue, TracesOrderBy, TracesPaginationRequest, TracesSearchResponse, TraceSummary, TracesPaginationResponse, TraceGetOptions, Trace, TraceSpan
  • Type-discriminated filter grammar (condition / and / or / not / text_search) with operators eq / neq / gt / gte / lt / lte / in / exists
  • TracesFilterValue encodes the typed-wrapper value form ({"type":"string","value":...}) and accepts the bare scalar/array form on decode
  • InsightsTraces* constants for filter node types, operators, scopes, sort directions, value types, and trace status
  • SearchTraces + GetTrace checks added to examples/insights/smoke/main.go

Plain-text error bodies from the traces service (400, 404 trace not found, 502) surface as ErrorResponse.Message via the existing CheckResponse fallback; covered by tests.

Testing

Rebased on main after #1156 (spans) merged; both clients coexist.

Unit / CI-equivalent — gofmt -s clean, go vet ./... clean, go test -race ./... passes on Go 1.23.12, 1.24.9 (CI matrix) and 1.27. New tests: TestInsights_SearchTraces, TestInsights_SearchTracesMinimalRequest, TestTracesFilterValueMarshal, TestTracesFilterValueUnmarshal, TestInsights_SearchTracesEscapesRegion, TestInsights_SearchTracesError, TestInsights_GetTrace, TestInsights_GetTraceNilOptions, TestInsights_GetTraceEscapesPath, TestInsights_GetTraceNotFound.

Live — examples/insights/smoke passes the traces checks on staging (s2r1) and prod (nyc2). A broader live matrix driven through this client against both environments: staging 59 passed / 2 skipped (no multi-span or second-region data), prod 61 passed, covering:

Area Cases
SearchTraces request relative, offset (now-168h), absolute RFC3339, absolute epoch-seconds time ranges; minimal body; summary field decoding
Pagination limit 1 (hasMore=true), 0 (server default), 1000
orderBy started asc/desc and durationNs desc verified sorted; serviceName, traceId, errorCount, spanCount, status, aliases; multiple clauses; omitted direction
Filters eq, neq, in (string_array), exists, gt/gte/lt/lte, bool value, empty type → condition, resource/attributes/span.attributes scopes, text_search, nested and/or/not, no-match → empty data
GetTrace nil options; span count / error count match the search summary; spans ordered by start; parent links (prod: 14 spans, 1 root, 13 linked); relative, RFC3339 and epoch-ms windows
Errors surfaced as *ErrorResponse 400 (plain text): from > to, range > 168h, limit 1001 / -1, missing timeRange, bad orderBy field / direction, not with 2 children, in with scalar; 404 (plain text): unknown, uppercase, out-of-window and wrong-region trace IDs; 404 / 401 (gateway JSON): unknown region, bad token

Note: the Insights query routes do not currently return the standard ratelimit-* headers (also true for logs search), so Response.Rate is empty for these calls. Tracking separately; no client change needed.

Jira: https://do-internal.atlassian.net/browse/COBS-1350

Add InsightsService.SearchTraces and GetTrace for the public traces query
endpoints documented in digitalocean/openapi#1256.
@srajputdo
srajputdo force-pushed the sakshirajput/COBS-1350/traces-query branch from 581fef7 to 5c0f0c6 Compare October 12, 2026 09:50
@srajputdo
srajputdo marked this pull request as ready for review October 12, 2026 10:02
@kishlay-singh-DO
kishlay-singh-DO merged commit eaf4e5e into digitalocean:main Oct 12, 2026
8 checks passed
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