[SDTEST-3776] Wire telemetry manager through the SDK to gather request/upload metrics#272
Merged
Merged
Conversation
…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) <noreply@anthropic.com>
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) <noreply@anthropic.com>
anmarchenko
approved these changes
Jun 3, 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.
What
Implements SDTEST-3776 — wires the common
Telemetrymanager (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)
EventsExporterstays telemetry-agnostic: it reports neutral facts through three observer protocols; all metric-name/tag mapping lives next to theTelemetrytree inDatadogSDKTesting.RequestObserver— one HTTP exchange: duration, request bytes (sent payload), response bytes, status. Measured once inHTTPClient.perform; threaded as an optional param through every API method (with@inlinableno-observer conveniences) and the upload calls.UploadObserver— background batch lifecycle inDataUploadWorker(attempt outcome;dropped).PayloadObserver— serialization time + event count per payload, inFileWriter.ExporterObservers, plumbed throughExporter→ spans/coverage sub-exporters.Also fixes a latent bug: the
*ApiServicetypes depended on the concreteHTTPClientinstead of the injectableHTTPClientTypeprotocol (despite aMockHTTPClientexisting for it).Consumer side (
DatadogSDKTesting)Telemetryis created with the tracer (before the exporter), exposed asDDTracer.telemetry, andSessionConfig.telemetrysources from it.Telemetry.metrics.*, with a sharedstatusCode → error_typederivation and per-family request observers.endpoint_payload.*— via the exporter observers (the only home for this family), taggedtest_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
ExporterConfigurationon 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.droppedwiring, 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