@grow-codes/datadog-apm - v0.1.1
    Preparing search index...

    Class DatadogSpansQuery

    Datadog spans query client (SaaS API at https://api.<site>, headers DD-API-KEY and DD-APPLICATION-KEY). Implements the SPEC TraceQueryClient on top of the spans search and aggregate APIs, plus Datadog-specific searchSpans, aggregateSpans and ping.

    Errors: 400/413/422 → ValidationError, 401 → AuthenticationError, 403 → PermissionDeniedError (AuthenticationError from ping()), 404 → NotFoundError, 408 → TimeoutError, 429 → RateLimitError (waits Retry-After / X-RateLimit-Reset within the retry budget), 5xx → UnavailableError.

    Hierarchy (View Summary)

    Index

    The configuration (API key, application key, site / API URL).

    • Releases connections. Idempotent.

      Returns Promise<void>

    • Reads a trace. Default: searches the indexed spans with trace_id:<id> over the last 24 hours (all pages, merged by span id) — only spans kept by retention filters, so the trace may be partial. With preview: true: GET /api/v2/trace/{id} (full trace, preview API). Returns null when nothing is found.

      Parameters

      Returns Promise<Trace | null>

    • Authenticated round trip GET /api/v2/validate_keys (API key + application key); returns the latency in ms. Invalid keys → AuthenticationError (Datadog answers 401 or 403).

      Parameters

      Returns Promise<number>

    • Iterates over every span matching the search, following the cursor page by page (same absolute window for every page). Throws TimeoutError when Datadog reports a timed-out query that returned no spans (never a silently empty result).

      Parameters

      Returns AsyncGenerator<DatadogSpan, void, undefined>

      for await (const s of query.searchSpans({ query: "service:checkout @grow.run:abc" })) {
      console.log(s.span.name, s.span.durationMicros);
      }