[SDTEST-3775] Add common telemetry manager with counter/histogram instances#271
Merged
Merged
Conversation
…tances Introduce a `Telemetry` manager (DatadogSDKTesting) that owns a MeterProvider wired to the Datadog instrumentation-telemetry metric pipeline (PeriodicMetricReader -> TelemetryMetricExporter -> TelemetryExporter, under the `civisibility` namespace) and provides an instrument for every CI Visibility metric. Metrics are exposed as a typed, discoverable tree - `telemetry.metrics.git.command.add(command: .getRepository)` - where each metric's add()/record() names exactly the tags it accepts and tag values are typed enums/Bool/Int rendered via the existing `SpanAttributeConvertible`. The metric set is taken from the shared instrumentation-telemetry spec and cross-checked against dd-trace-go (59 metrics: 37 counters + 22 distributions). This only provides the instances; features do not record into them yet. - EventsExporter: make TelemetryMetricExporter / TelemetryLogExporter public; add `civisibility` to the metric/distribution namespace enums. - Config: add DD_INSTRUMENTATION_TELEMETRY_ENABLED (default true) and DD_TELEMETRY_HEARTBEAT_INTERVAL (seconds, clamped 1...3600, default 60). - SessionManager: build the Telemetry manager (gated by the enable flag) and thread it through the optional SessionConfig.telemetry; shut it down on stop. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This comment has been minimized.
This comment has been minimized.
anmarchenko
approved these changes
Jun 3, 2026
The `appendToOneFile` storage mock used `minFileAgeForRead: -1`, making the still-open file immediately eligible for the periodic upload worker (firing every 0.05s). When the worker fired between the test's synchronous writes it uploaded and deleted the file after only some entries, splitting the batch across uploads and intermittently failing the 4-entry assertion. `flush()` drains via `getAllReadableFiles()`, which ignores `minFileAgeForRead`, so setting it to `.greatestFiniteMagnitude` keeps the periodic worker from ever racing the writes while flush still drains the whole file as one batch — exactly the behaviour under test. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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-3775 — the first piece of M3 (gather SDK metrics). Adds a common telemetry manager that owns the metric pipeline and provides a counter/histogram instance for every CI Visibility metric.
This PR only provides the instances; features do not record into them yet (that's the follow-up "gather" subtask).
Design
Telemetry(DatadogSDKTesting) owns aMeterProviderSdkwired to the Datadog instrumentation-telemetry pipeline:PeriodicMetricReader → TelemetryMetricExporter → TelemetryExporter, with thecivisibilitynamespace stamped on the meterResource.add/recordnames exactly the tags it accepts. Tag values are typed enums /Bool/Int, rendered to wire strings via the existingSpanAttributeConvertible.dd-trace-go— 59 metrics (37 counters + 22 distributions), so nothing is missed.Configuration
DD_INSTRUMENTATION_TELEMETRY_ENABLED— defaulttrue; when off,SessionConfig.telemetryisnil.DD_TELEMETRY_HEARTBEAT_INTERVAL— collection/export interval in seconds, clamped to1...3600, default60.Changes
TelemetryMetricExporter/TelemetryLogExporterpublic (were internal only because previously unused); addedcivisibilityto the metric & distribution namespace enums.SessionConfig.telemetry, and shuts it down on stop.Testing
New
TelemetryTestsverify the typed tags map to correct wire values (command:get_repository,error_type:timeout,endpoint:test_cycle), thecivisibilitynamespace, and counter increment values. Build +TelemetryTests/ConfigTestspass; the fullEventsExportersuite still passes.🤖 Generated with Claude Code