Skip to content

[SDTEST-3776] Wire telemetry manager through the SDK to gather request/upload metrics#272

Merged
ypopovych merged 2 commits into
mainfrom
yehor.popovych/sdtest-3776-wire-telemetry
Jun 3, 2026
Merged

[SDTEST-3776] Wire telemetry manager through the SDK to gather request/upload metrics#272
ypopovych merged 2 commits into
mainfrom
yehor.popovych/sdtest-3776-wire-telemetry

Conversation

@ypopovych

@ypopovych ypopovych commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

What

Implements SDTEST-3776 — wires the common Telemetry manager (added in #271) through the SDK so the network/storage layers and the API-calling features can record CI Visibility metrics. Builds on the typed metric tree from 3775.

Design — observer hooks (dependency inversion)

EventsExporter stays telemetry-agnostic: it reports neutral facts through three observer protocols; all metric-name/tag mapping lives next to the Telemetry tree in DatadogSDKTesting.

  • RequestObserver — one HTTP exchange: duration, request bytes (sent payload), response bytes, status. Measured once in HTTPClient.perform; threaded as an optional param through every API method (with @inlinable no-observer conveniences) and the upload calls.
  • UploadObserver — background batch lifecycle in DataUploadWorker (attempt outcome; dropped).
  • PayloadObserver — serialization time + event count per payload, in FileWriter.
  • Bundled as ExporterObservers, plumbed through Exporter → spans/coverage sub-exporters.

Also fixes a latent bug: the *ApiService types depended on the concrete HTTPClient instead of the injectable HTTPClientType protocol (despite a MockHTTPClient existing for it).

Consumer side (DatadogSDKTesting)

  • Telemetry is created with the tracer (before the exporter), exposed as DDTracer.telemetry, and SessionConfig.telemetry sources from it.
  • Observer adapters map the neutral callbacks to Telemetry.metrics.*, with a shared statusCode → error_type derivation and per-family request observers.
  • Gathered now:
    • endpoint_payload.* — via the exporter observers (the only home for this family), tagged test_cycle (spans) / code_coverage (coverage).
    • git_requests.*, itr_skippable_tests.*, known_tests.*, test_management_tests.* — via per-call request observers threaded into the git uploader, TIA / known-tests / test-management factories and the settings fetch.

Notable change

The exporter and telemetry now share a single ExporterConfiguration on the default performance preset (previously the exporter used .instantDataDelivery). Flush-on-shutdown still delivers everything; in-run uploads are less eager.

Out of scope (→ SDTEST-3777)

Response item counts (response_tests/suites/files, objects_pack_files, settings_response) from parsed results, endpoint_payload.dropped wiring, and the local feature metrics (events.*, git.command, itr.skipped, code_coverage.*, test_session, …).

Testing

New unit tests for each observer hook (FileWriter, DataUploadWorker) and the adapters (error-type mapping, request forwarding). Full suites pass: EventsExporter 132, DatadogSDKTesting all green.

🤖 Generated with Claude Code

…t/upload metrics

Introduce telemetry observer hooks in EventsExporter and wire the common
`Telemetry` manager through the tracer so the network/storage layers and the
API-calling features can record CI Visibility metrics.

EventsExporter (producer side — telemetry-agnostic):
- Add `RequestObserver` (HTTP request: duration, request/response bytes, status),
  `UploadObserver` (background batch lifecycle) and `PayloadObserver`
  (serialization time + event count) protocols.
- Measure request facts once in `HTTPClient.perform`; thread an optional
  `observer` through every API method (with `@inlinable` no-observer
  conveniences) and the upload pipeline (`DataUploadWorker`, `FileWriter`).
- Bundle them as `ExporterObservers` plumbed through `Exporter` to the spans /
  coverage sub-exporters.
- Fix `*ApiService` to depend on `HTTPClientType` instead of the concrete
  `HTTPClient` (they bypassed the injectable protocol).

DatadogSDKTesting (consumer side):
- Create the `Telemetry` manager with the tracer (before the exporter) so it can
  observe the upload pipeline and reach the feature factories; expose it as
  `DDTracer.telemetry` and source `SessionConfig.telemetry` from it.
- Add observer adapters mapping the neutral callbacks to `Telemetry.metrics.*`
  with a shared `statusCode -> error_type` derivation, plus per-family request
  observers.
- Gather `endpoint_payload.*` (via the exporter observers) and the API-request
  families `git_requests.*` / `itr_skippable_tests.*` / `known_tests.*` /
  `test_management_tests.*` (via per-call request observers threaded into the
  git uploader, TIA / known-tests / test-management factories and the settings
  fetch).

Reuse a single `ExporterConfiguration` for the exporter and telemetry, now on
the default performance preset.

Response item counts and the local feature metrics (events, git commands, ITR
decisions, code coverage) remain for SDTEST-3777.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@ypopovych
ypopovych requested review from a team as code owners June 3, 2026 14:14
Describes the metric tree (3775), the observer-hook wiring (3776), what is
gathered today vs. the remaining work for SDTEST-3777 (response item counts,
endpoint_payload.dropped, local feature metrics), the cross-module rationale,
lifecycle, gotchas and a file map.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@ypopovych
ypopovych requested a review from anmarchenko June 3, 2026 14:36
@ypopovych
ypopovych merged commit e9db1c7 into main Jun 3, 2026
11 checks passed
@ypopovych
ypopovych deleted the yehor.popovych/sdtest-3776-wire-telemetry branch June 3, 2026 14:39
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