Skip to content

timeseries [6/6] RUM-13949 Add end-to-end timeseries verification tests with CSV fixtures#3436

Draft
satween wants to merge 16 commits into
tvaleev/feature/RUM-13949/timeseries-rum-session-wiringfrom
tvaleev/feature/RUM-13949/timeseries-e2e-csv-fixtures
Draft

timeseries [6/6] RUM-13949 Add end-to-end timeseries verification tests with CSV fixtures#3436
satween wants to merge 16 commits into
tvaleev/feature/RUM-13949/timeseries-rum-session-wiringfrom
tvaleev/feature/RUM-13949/timeseries-e2e-csv-fixtures

Conversation

@satween
Copy link
Copy Markdown
Contributor

@satween satween commented May 12, 2026

What does this PR do?

Adds a self-contained end-to-end test suite for the timeseries pipeline using CSV-driven input fixtures and golden JSON files, without any real Android API dependencies. Includes CSVReader, CsvTimeseries (a synchronous, executor-free test double mirroring RumSessionScopeTimeseriesFactory), TimeseriesEndToEndTest, and the accompanying CSV input and expected JSON fixture files.

Motivation

Provides regression coverage that the full memory and CPU batch outputs match the expected wire format exactly, catching any serialization regressions independently of mock-heavy unit tests.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

Copy link
Copy Markdown
Contributor Author

satween commented May 12, 2026

@satween satween changed the title RUM-13949 Add end-to-end timeseries verification tests with CSV fixtures timeseries RUM-13949 Add end-to-end timeseries verification tests with CSV fixtures May 12, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.15%. Comparing base (cd319d9) to head (de29adf).

Additional details and impacted files
@@                                     Coverage Diff                                     @@
##           tvaleev/feature/RUM-13949/timeseries-rum-session-wiring    #3436      +/-   ##
===========================================================================================
- Coverage                                                    72.16%   72.15%   -0.01%     
===========================================================================================
  Files                                                          973      973              
  Lines                                                        35718    35718              
  Branches                                                      5934     5934              
===========================================================================================
- Hits                                                         25775    25771       -4     
- Misses                                                        8320     8325       +5     
+ Partials                                                      1623     1622       -1     

see 39 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-rum-session-wiring branch from f630b6d to 3b05b0c Compare May 13, 2026 13:43
@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-e2e-csv-fixtures branch 2 times, most recently from 47a028b to c082086 Compare May 13, 2026 14:44
@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-rum-session-wiring branch from 3b05b0c to 9d01d39 Compare May 13, 2026 14:44
Introduces the core primitives for the timeseries data pipeline: `Timeseries` interface (with `@NoOpImplementation`), `DataPoint`, `Buffer`, `DeltaCompression`, `Pipeline`, `EventWriter`, `JsonSerializer` interface, `DataPointsReader` interface, `VitalReaderWrapper`, and the generic `RumSessionScopeTimeseries` per-session collector. Also adds detekt safe-call allowlist entries for the new APIs.

### What does this PR do?

Adds the foundational building blocks shared by all timeseries metric types: the `Timeseries` lifecycle interface, immutable `DataPoint`, the `Buffer`/`DeltaCompression`/`Pipeline` data-processing chain, the `EventWriter` flush boundary, `JsonSerializer` interface, `DataPointsReader`/`VitalReaderWrapper` for OS-metric abstraction, and `RumSessionScopeTimeseries` — the generic per-session scheduler that drives sampling, batching, and writing for any metric type.

### Motivation

Establishes the shared infrastructure that CPU and memory collectors will extend, keeping primitive types and pipeline logic isolated so they can be reviewed without metric-specific details.

### Additional Notes

Unit tests cover all primitives. `DataPointForgeryFactory` and the `Configurator` registration are included so subsequent commits can write tests against generated `DataPoint` values. `RumSessionTypeExt` session-type mappings are added here (used by both CPU and memory serializers in later commits).
@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-e2e-csv-fixtures branch from c082086 to ac44f0c Compare May 14, 2026 19:40
@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-rum-session-wiring branch 2 times, most recently from 8ea9614 to 9a49aaa Compare May 20, 2026 15:27
@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-e2e-csv-fixtures branch from ac44f0c to 92af517 Compare May 20, 2026 15:27
@datadog-prod-us1-6

This comment has been minimized.

@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-rum-session-wiring branch from 9a49aaa to 0db4915 Compare May 21, 2026 19:40
@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-e2e-csv-fixtures branch from 92af517 to de1c9de Compare May 21, 2026 19:46
@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-rum-session-wiring branch from 0db4915 to 91bf158 Compare May 21, 2026 20:16
@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-e2e-csv-fixtures branch from de1c9de to 15f936e Compare May 21, 2026 20:16
satween and others added 3 commits May 22, 2026 13:58
- Switch `RumSessionScopeTimeseries` from owning a per-session executor to accepting a shared `ScheduledExecutorService` (no creation, no shutdown).
- Add `RumSessionScopeTimeseriesFactory` so reviewers can see how `RumSessionScopeTimeseries` is instantiated.
- Wire timeseries `start`/`stop` lifecycle into `RumSessionScope` (`startTimeseries`/`stopTimeseries` called from `renewSession`/`stopSession`).
- Remove 3 unused entries added to `detekt_custom_safe_calls.yml` in this branch.
### What does this PR do?

Adds `CpuDatapointReader`, which reads CPU-usage metrics from the existing `CpuVitalReader` vital and wraps them as `DataPoint` values; and `CpuEventSerializer`, which converts a batch of CPU `DataPoint`s into a `RumTimeseriesCpuEvent` JSON object ready for ingestion.

### Motivation

Implements CPU metric collection as the first concrete timeseries type, exercising the pipeline infrastructure introduced in the previous commit.

### Additional Notes

`CpuDatapointReader` normalises the raw MHz value to a 0–100 percent scale and clamps it with `coerceIn`. `CpuEventSerializer` maps `RumSessionType` to `RumTimeseriesCpuEvent.Session.Type` via the `toTimeseriesCpuSessionType()` extension. Both classes are fully covered by unit tests.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-e2e-csv-fixtures branch from 15f936e to 5a583ff Compare May 22, 2026 13:01
@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-rum-session-wiring branch from 91bf158 to 7298723 Compare May 22, 2026 13:01
satween and others added 3 commits May 22, 2026 14:50
…ions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds `MemoryEventSerializer`, which converts a batch of memory `DataPoint`s (heap + native RSS) into a `RumTimeseriesMemoryEvent` JSON object. Introduces `TimeseriesConfiguration` as the public `@ExperimentalRumApi` configuration class (sampling intervals, batch size, background collection flag). Completes the pipeline with `RumSessionScopeTimeseriesFactory`, which wires CPU and memory readers, serializers, and the `TimeseriesConfiguration` together to create fully configured `RumSessionScopeTimeseries` instances for each new session.

Completes the two metric types and provides the factory needed to tie the pipeline to the RUM session lifecycle.

`MemoryEventSerializer` reports both heap and native RSS in bytes, normalised to a 0–100 percent scale using device `maxMemory`. `RumSessionScopeTimeseriesFactory` creates one pipeline per metric type and dispatches them through the same `Timeseries.Factory` interface. `TimeseriesConfiguration` exposes sampling interval, batch size, and a background-collection flag with sensible defaults.
satween and others added 9 commits May 22, 2026 14:53
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds `enableTimeseries()`/`disableTimeseries()` builder methods on `RumConfiguration.Builder`. Wires the `Timeseries.Factory` through `RumFeature` → `DatadogRumMonitor` → `RumApplicationScope` → `RumSessionScope`, so that a new `RumSessionScopeTimeseries` collector is created and started for each sampled session and stopped on session end or SDK teardown. Also enables timeseries in the Kotlin sample app.

Connects the standalone pipeline and public configuration API to the existing RUM session lifecycle, completing the end-to-end data flow from configuration through to event emission.

Existing scope and monitor test scaffolding is updated to pass `timeseriesFactory = null` / a mock factory where required. The `RumFeature.onStop()` ordering test verifies the writer is still live when the final flush fires.
…ctivityManager cast

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
MemoryInfo() and getMemoryInfo() are listed in knownThrowingCalls
as they can throw RuntimeException on broken Android implementations.
Extract to readTotalRamBytes() with a safe RuntimeException catch
and WARN log, falling back to 0.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
### What does this PR do?

Adds a self-contained end-to-end test suite for the timeseries pipeline using CSV-driven input fixtures and golden JSON files, without any real Android API dependencies. Includes `CSVReader`, `CsvTimeseries` (a synchronous, executor-free test double mirroring `RumSessionScopeTimeseriesFactory`), `TimeseriesEndToEndTest`, and the accompanying CSV input and expected JSON fixture files.

### Motivation

Provides regression coverage that the full memory and CPU batch outputs match the expected wire format exactly, catching any serialization regressions independently of mock-heavy unit tests.

### Additional Notes

Fixtures use a fixed 10-sample / 2-batch scenario. Numeric comparisons use a small relative tolerance for floating-point memory_percent values.
- DataPoint(timestamp→timestampNs), onSessionStart/Stop, remove unsafe ?. call

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-rum-session-wiring branch from 7298723 to cd319d9 Compare May 22, 2026 14:52
@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-e2e-csv-fixtures branch from 5a583ff to de29adf Compare May 22, 2026 14:52
@satween satween changed the title timeseries RUM-13949 Add end-to-end timeseries verification tests with CSV fixtures timeseries [6/6] RUM-13949 Add end-to-end timeseries verification tests with CSV fixtures May 25, 2026
@satween satween force-pushed the tvaleev/feature/RUM-13949/timeseries-rum-session-wiring branch from cd319d9 to ac48ae9 Compare May 27, 2026 09:59
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