Skip to content

[SDTEST-3769] Telemetry API wrapper (metrics, logs, batches, app lifecycle)#256

Merged
ypopovych merged 1 commit into
mainfrom
SDTEST-3769-telemetry-api
May 18, 2026
Merged

[SDTEST-3769] Telemetry API wrapper (metrics, logs, batches, app lifecycle)#256
ypopovych merged 1 commit into
mainfrom
SDTEST-3769-telemetry-api

Conversation

@ypopovych

Copy link
Copy Markdown
Contributor

Summary

  • New TelemetryApi / TelemetryApiService in Sources/EventsExporter/API/TelemetryApi.swift, posting to the agentless /api/v2/apmtelemetry intake on instrumentation-telemetry-intake.<site>. Owns a per-runtime seq_id counter (overflow-safe with &+=) and reuses APIServiceConfig.clientId as the telemetry runtime_id so the backend can correlate telemetry with traces.
  • Metrics / logs: sendMetrics(_:namespace:) and sendLogs(_:). Public domain types: TelemetryMetric.{Series, Point, MetricType, Namespace} and TelemetryLog / TelemetryLog.Level. Point encodes as [ts, value] per spec.
  • App lifecycle: sendAppStarted(products:configuration:error:installSignature:), sendAppHeartbeat(), sendAppClosing(). Public types: TelemetryError, TelemetryProductInfo, TelemetryProducts, TelemetryConfigItem, TelemetryConfigOrigin, TelemetryInstallSignature. Heartbeat/closing emit payload: {} to satisfy the envelope schema.
  • Batching: 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 the LogsApi/SpansApi shape. TelemetryBatchEntry is a tagged enum (no AnyEncodable).
  • Wiring: APIServiceConfig gains serviceName and environment (used by the telemetry application/host blocks). TestOptimizationApi/Service exposes var telemetry: TelemetryApi.
  • Shared: Synced / UnfairLock / LazySynced moved from DatadogSDKTesting/Utils/Synced.swiftEventsExporter/Utils/Synced.swift and made public so both modules share them. DatadogSDKTesting source/test files that consume Synced import EventsExporter.
  • Misc: GitUploadApi.uploadPackFiles now uploads files concurrently via withThrowingTaskGroup.

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 test for EventsExporter on macOS arm64 — 95/95 passing
  • xcodebuild build for DatadogSDKTesting on macOS arm64 — clean
  • Manual smoke against a real telemetry intake (Datadog staging) once a consumer is wired up

🤖 Generated with Claude Code

…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]>
@ypopovych
ypopovych requested review from a team as code owners May 15, 2026 17:05
@ypopovych
ypopovych merged commit be3faff into main May 18, 2026
31 of 32 checks passed
@ypopovych
ypopovych deleted the SDTEST-3769-telemetry-api branch May 18, 2026 10:07
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