Skip to content

RUM-767: Improve reading-errors telemetry for dropped events - #3598

Open
satween wants to merge 1 commit into
developfrom
tvaleev/feature/RUM-767-dropped-events-rum
Open

RUM-767: Improve reading-errors telemetry for dropped events#3598
satween wants to merge 1 commit into
developfrom
tvaleev/feature/RUM-767-dropped-events-rum

Conversation

@satween

@satween satween commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Improves internal telemetry for events dropped during file read/write on the persistence layer:

  • Adds TelemetryAttributes (feature.name, event.dropped_bytes) so dropped-event error telemetry carries consistent, queryable attributes across features (RUM, logs, tracing) and across read/write paths.
  • Threads these attributes through RumDataWriter, FileEventBatchWriter, BatchFileReaderWriter/PlainBatchFileReaderWriter, TLVBlock/TLVBlockFileReader, CoreFeature, and SdkFeature so telemetry errors report which feature and how many bytes were involved when an event is dropped.
  • Fixes a detekt violation introduced by the above changes.

Motivation

When events are dropped during persistence (e.g. oversized batches), the existing telemetry lacked enough context to diagnose which feature was affected and how large the dropped payload was. RUM-767 tracks improving this visibility.

Additional Notes

  • New/updated unit tests for TLVBlockFileReader, RumDataWriter, FileEventBatchWriter, BatchFileReaderWriter/PlainBatchFileReaderWriter, TLVBlock.
  • dd-sdk-android-internal public API surface updated (apiSurface / .api files) for the new TelemetryAttributes object.
  • Draft PR — pushed directly per request; full local_ci (tests/lint/apiSurface regen) has not been re-run as part of this push.

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)

@codecov-commenter

codecov-commenter commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.27451% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.37%. Comparing base (b78b347) to head (e44eaf1).
⚠️ Report is 5 commits behind head on develop.

Files with missing lines Patch % Lines
...rsistence/file/batch/PlainBatchFileReaderWriter.kt 76.19% 9 Missing and 1 partial ⚠️
...tadog/android/rum/internal/domain/RumDataWriter.kt 79.17% 0 Missing and 5 partials ⚠️
.../core/internal/persistence/FileEventBatchWriter.kt 80.00% 0 Missing and 2 partials ⚠️
...droid/internal/telemetry/BatchTelemetryMetadata.kt 80.00% 2 Missing ⚠️
...in/com/datadog/android/core/internal/SdkFeature.kt 80.00% 1 Missing ⚠️
...rsistence/file/batch/EncryptedBatchReaderWriter.kt 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3598      +/-   ##
===========================================
+ Coverage    73.31%   73.37%   +0.05%     
===========================================
  Files          995      996       +1     
  Lines        36312    36378      +66     
  Branches      6134     6156      +22     
===========================================
+ Hits         26622    26689      +67     
+ Misses        7983     7977       -6     
- Partials      1707     1712       +5     
Files with missing lines Coverage Δ
...n/com/datadog/android/api/storage/RawBatchEvent.kt 80.00% <100.00%> (+5.00%) ⬆️
...n/com/datadog/android/core/internal/CoreFeature.kt 88.80% <100.00%> (+0.03%) ⬆️
...d/core/internal/persistence/ConsentAwareStorage.kt 93.98% <100.00%> (+0.07%) ⬆️
...ernal/persistence/datastore/DatastoreFileWriter.kt 85.00% <100.00%> (+0.52%) ⬆️
...al/persistence/file/batch/BatchFileReaderWriter.kt 100.00% <100.00%> (ø)
...id/core/internal/persistence/tlvformat/TLVBlock.kt 100.00% <100.00%> (ø)
...ternal/persistence/tlvformat/TLVBlockFileReader.kt 100.00% <100.00%> (ø)
...in/com/datadog/android/core/internal/SdkFeature.kt 90.05% <80.00%> (+0.09%) ⬆️
...rsistence/file/batch/EncryptedBatchReaderWriter.kt 88.00% <80.00%> (+1.04%) ⬆️
.../core/internal/persistence/FileEventBatchWriter.kt 93.10% <80.00%> (-3.12%) ⬇️
... and 3 more

... and 33 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 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves internal telemetry for persistence-layer drops and read/write errors by introducing consistent attribute keys (e.g., feature.name, event.dropped_bytes) and threading feature context through the persistence stack so telemetry is easier to query across features and code paths.

Changes:

  • Added TelemetryAttributes (internal module) and updated API surface files accordingly.
  • Propagated featureName/size context through core persistence components (FileEventBatchWriter, BatchFileReaderWriter/PlainBatchFileReaderWriter, SdkFeature, CoreFeature) and updated unit tests.
  • Added a max-item-size drop path in RumDataWriter with telemetry/user logging and expanded RUM unit tests for size-exceeded scenarios.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
features/dd-sdk-android-rum/src/test/kotlin/com/datadog/android/rum/internal/domain/RumDataWriterTest.kt Adds unit coverage for RUM events dropped when serialized payload exceeds maxItemSize.
features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/RumFeature.kt Wires storageConfiguration.maxItemSize into RumDataWriter.
features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/RumDataWriter.kt Adds size-limit drop handling with user+telemetry logging and dropped-bytes attribute.
dd-sdk-android-internal/src/main/java/com/datadog/android/internal/telemetry/TelemetryAttributes.kt Introduces shared telemetry attribute keys for persistence diagnostics.
dd-sdk-android-internal/api/dd-sdk-android-internal.api API dump updated for the new TelemetryAttributes public type.
dd-sdk-android-internal/api/apiSurface API surface updated to include TelemetryAttributes.
dd-sdk-android-core/src/test/kotlin/com/datadog/android/core/internal/persistence/tlvformat/TLVBlockTest.kt Updates expectations for TLV serialization oversize logging targets/level.
dd-sdk-android-core/src/test/kotlin/com/datadog/android/core/internal/persistence/tlvformat/TLVBlockFileReaderTest.kt Adds/updates tests for invalid TLV declared length handling and logging.
dd-sdk-android-core/src/test/kotlin/com/datadog/android/core/internal/persistence/FileEventBatchWriterTest.kt Updates tests for new telemetry targets and added dropped-bytes/feature attributes.
dd-sdk-android-core/src/test/kotlin/com/datadog/android/core/internal/persistence/file/batch/PlainBatchFileReaderWriterTest.kt Updates tests for new constructor signature and feature-name telemetry attributes.
dd-sdk-android-core/src/test/kotlin/com/datadog/android/core/internal/persistence/file/batch/BatchFileReaderWriterTest.kt Updates tests for create(..., featureName) signature.
dd-sdk-android-core/src/test/kotlin/com/datadog/android/core/internal/CoreFeatureTest.kt Updates usage of BatchFileReaderWriter.create to include feature name.
dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/SdkFeature.kt Threads featureName into persistence reader/writer creation.
dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/persistence/tlvformat/TLVBlockFileReader.kt Adds declared-length validation with telemetry/user error logging.
dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/persistence/tlvformat/TLVBlock.kt Changes oversize TLV serialization log to ERROR and USER+TELEMETRY; exposes size constant internally.
dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/persistence/FileEventBatchWriter.kt Adds featureName and attaches feature.name + event.dropped_bytes on oversize drops.
dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/persistence/file/batch/PlainBatchFileReaderWriter.kt Adds featureName and attaches it to read-side telemetry errors/warnings.
dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/persistence/file/batch/BatchFileReaderWriter.kt Extends factory to require featureName and passes it down.
dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/persistence/ConsentAwareStorage.kt Passes featureName into FileEventBatchWriter.
dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/CoreFeature.kt Ensures core-created batch reader/writers include Feature.RUM_FEATURE_NAME.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cfc0a6226a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@satween
satween force-pushed the tvaleev/feature/RUM-767-dropped-events-rum branch 2 times, most recently from 9307351 to c7c311f Compare July 9, 2026 11:08
@satween
satween requested review from Copilot and jonathanmos July 9, 2026 11:10
@satween
satween marked this pull request as ready for review July 9, 2026 11:10
@satween
satween requested review from a team as code owners July 9, 2026 11:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/persistence/tlvformat/TLVBlockFileReader.kt:102

  • readData() uses copyOfRangeSafe(newIndex, newIndex + lengthData) but never checks that the requested range is actually present in inputArray. If the file is truncated, copyOfRangeSafe returns an empty array and the reader will still advance newIndex and return a block, which can later crash (e.g. ByteArray.toInt() on empty data in DatastoreFileReader). Add an explicit bounds check and treat this as a deserialize failure.
        val dataBytes = inputArray.copyOfRangeSafe(newIndex, newIndex + lengthData)

        newIndex += lengthData

        return TLVResult(

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c7c311f9e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@satween
satween force-pushed the tvaleev/feature/RUM-767-dropped-events-rum branch 2 times, most recently from a326ebc to ad3f057 Compare July 9, 2026 15:14

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad3f05750b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@satween
satween force-pushed the tvaleev/feature/RUM-767-dropped-events-rum branch from ad3f057 to 8a88098 Compare July 10, 2026 13:34
@satween
satween force-pushed the tvaleev/feature/RUM-767-dropped-events-rum branch from 8a88098 to 973960e Compare July 17, 2026 15:49

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 973960e048

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@satween
satween force-pushed the tvaleev/feature/RUM-767-dropped-events-rum branch from 973960e to e44eaf1 Compare July 20, 2026 14:42

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e44eaf10ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@satween
satween force-pushed the tvaleev/feature/RUM-767-dropped-events-rum branch from e44eaf1 to d40d544 Compare July 20, 2026 16:35

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d40d54444d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

5 participants