[SDTEST-3769] Telemetry API wrapper (metrics, logs, batches, app lifecycle)#256
Merged
Conversation
…lifecycle)
Add an agentless Telemetry API wrapper alongside the existing TestOptimization
APIs. Sends to /api/v2/apmtelemetry on instrumentation-telemetry-intake.<site>.
Owns a per-runtime seq_id counter (overflow-safe via &+=) and reuses the
exporter's client UUID as runtime_id so telemetry correlates with traces.
Methods:
- sendMetrics(_:namespace:) and sendLogs(_:) for the two metrics/logs request
types. Public domain types: TelemetryMetric.{Series,Point,MetricType,Namespace}
and TelemetryLog{.Level}. Point encodes as [ts, value] per spec.
- sendAppStarted(products:configuration:error:installSignature:),
sendAppHeartbeat(), sendAppClosing() for the lifecycle events. Public types:
TelemetryError, TelemetryProductInfo, TelemetryProducts, TelemetryConfigItem,
TelemetryConfigOrigin, TelemetryInstallSignature. Heartbeat / closing emit
payload: {} since the envelope schema requires payload.
- send(batch:) overloaded for [TelemetryBatchItem], URL, and Data. The
structured variant wraps inner request_types as a message-batch with a fresh
envelope; the URL/Data variants POST a pre-built envelope verbatim
(matching LogsApi/SpansApi shape).
Other changes:
- APIServiceConfig gains serviceName/environment (used by the telemetry
application/host blocks).
- Synced/UnfairLock/LazySynced moved from DatadogSDKTesting/Utils/Synced.swift
to EventsExporter/Utils/Synced.swift and made public so both modules share
them; DatadogSDKTesting files that consume Synced now import EventsExporter.
- GitUploadApi.uploadPackFiles uploads files concurrently via
withThrowingTaskGroup.
Telemetry is exposed but not yet consumed by EventsExporter; future work will
wire it into the upload pipeline.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
anmarchenko
approved these changes
May 18, 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.
Summary
TelemetryApi/TelemetryApiServiceinSources/EventsExporter/API/TelemetryApi.swift, posting to the agentless/api/v2/apmtelemetryintake oninstrumentation-telemetry-intake.<site>. Owns a per-runtimeseq_idcounter (overflow-safe with&+=) and reusesAPIServiceConfig.clientIdas the telemetryruntime_idso the backend can correlate telemetry with traces.sendMetrics(_:namespace:)andsendLogs(_:). Public domain types:TelemetryMetric.{Series, Point, MetricType, Namespace}andTelemetryLog/TelemetryLog.Level.Pointencodes as[ts, value]per spec.sendAppStarted(products:configuration:error:installSignature:),sendAppHeartbeat(),sendAppClosing(). Public types:TelemetryError,TelemetryProductInfo,TelemetryProducts,TelemetryConfigItem,TelemetryConfigOrigin,TelemetryInstallSignature. Heartbeat/closing emitpayload: {}to satisfy the envelope schema.send(batch:)overloaded for[TelemetryBatchItem],URL, andData. The structured variant wraps inner request types as amessage-batchwith a fresh envelope; the URL/Data variants POST a pre-built envelope verbatim, matching theLogsApi/SpansApishape.TelemetryBatchEntryis a tagged enum (noAnyEncodable).APIServiceConfiggainsserviceNameandenvironment(used by the telemetry application/host blocks).TestOptimizationApi/Serviceexposesvar telemetry: TelemetryApi.Synced/UnfairLock/LazySyncedmoved fromDatadogSDKTesting/Utils/Synced.swift→EventsExporter/Utils/Synced.swiftand madepublicso both modules share them. DatadogSDKTesting source/test files that consumeSyncedimportEventsExporter.GitUploadApi.uploadPackFilesnow uploads files concurrently viawithThrowingTaskGroup.Telemetry is exposed via the API surface but not yet consumed by
EventsExporter— wiring it into an upload pipeline is follow-up work.Test plan
xcodebuild testforEventsExporteron macOS arm64 — 95/95 passingxcodebuild buildforDatadogSDKTestingon macOS arm64 — clean🤖 Generated with Claude Code