Skip to content

RUM-14782: Capture OkHttp Network Headers#3204

Open
kikoveiga wants to merge 3 commits intodevelopfrom
kikoveiga/RUM-14782/capture-okhttp-network-headers
Open

RUM-14782: Capture OkHttp Network Headers#3204
kikoveiga wants to merge 3 commits intodevelopfrom
kikoveiga/RUM-14782/capture-okhttp-network-headers

Conversation

@kikoveiga
Copy link
Contributor

@kikoveiga kikoveiga commented Feb 27, 2026

What does this PR do?

  • Add new trackResourceHeaders public api in DatadogInterceptor.
  • Add new attributes for request and response headers in RumAttributes.
  • Extract the contents of these attributes in RumResourceScope and add them to the resource.
  • Business logic in ResourceHeadersExtractor.
  • Disable caches of networking libraries used in the sample app.

Motivation

Customers weren't able to easily capture network headers, having to do it manually (e.g., by creating custom attributes).

Additional notes

Here is an example taken from the sample app:

image

This is aligned with the iOS implementation:

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)

@kikoveiga kikoveiga force-pushed the kikoveiga/RUM-14782/capture-okhttp-network-headers branch from 4ed9e06 to a082ecb Compare February 27, 2026 10:37
@datadog-datadog-prod-us1

This comment has been minimized.

@kikoveiga kikoveiga changed the title [RUM-14782] Capture OkHttp Network Headers RUM-14782: Capture OkHttp Network Headers Feb 27, 2026
@codecov-commenter
Copy link

codecov-commenter commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 80.70175% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.45%. Comparing base (6d0fdb6) to head (6db4618).

Files with missing lines Patch % Lines
...om/datadog/android/rum/internal/utils/StringExt.kt 39.13% 14 Missing ⚠️
.../rum/configuration/ResourceHeadersConfiguration.kt 91.11% 3 Missing and 1 partial ⚠️
...roid/rum/internal/domain/scope/RumResourceScope.kt 72.73% 0 Missing and 3 partials ⚠️
...droid/rum/internal/net/ResourceHeadersExtractor.kt 95.45% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3204      +/-   ##
===========================================
+ Coverage    71.41%   71.45%   +0.04%     
===========================================
  Files          933      936       +3     
  Lines        34591    34682      +91     
  Branches      5849     5866      +17     
===========================================
+ Hits         24701    24780      +79     
- Misses        8253     8263      +10     
- Partials      1637     1639       +2     
Files with missing lines Coverage Δ
...n/com/datadog/android/okhttp/DatadogInterceptor.kt 74.63% <100.00%> (+1.95%) ⬆️
...droid/rum/internal/net/ResourceHeadersExtractor.kt 95.45% <95.45%> (ø)
...roid/rum/internal/domain/scope/RumResourceScope.kt 94.40% <72.73%> (+3.34%) ⬆️
.../rum/configuration/ResourceHeadersConfiguration.kt 91.11% <91.11%> (ø)
...om/datadog/android/rum/internal/utils/StringExt.kt 39.13% <39.13%> (ø)

... and 40 files with indirect coverage changes

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

@kikoveiga kikoveiga force-pushed the kikoveiga/RUM-14782/capture-okhttp-network-headers branch 9 times, most recently from 998a873 to 789aef2 Compare March 2, 2026 16:34
@kikoveiga kikoveiga self-assigned this Mar 2, 2026
@kikoveiga kikoveiga force-pushed the kikoveiga/RUM-14782/capture-okhttp-network-headers branch 6 times, most recently from d99452e to de59997 Compare March 2, 2026 18:37
@kikoveiga kikoveiga marked this pull request as ready for review March 3, 2026 10:40
@kikoveiga kikoveiga requested review from a team as code owners March 3, 2026 10:40
Copy link

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

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: de599972f2

ℹ️ 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".

@kikoveiga kikoveiga force-pushed the kikoveiga/RUM-14782/capture-okhttp-network-headers branch from de59997 to 8aed174 Compare March 3, 2026 11:04
const val GRAPHQL_ERRORS: String = "_dd.graphql.errors"

/**
* The request headers of the resource. (Map<String, String>)
Copy link
Member

Choose a reason for hiding this comment

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

It is not quite clear what is expected to be key and value of this map, given that per HTTP spec headers can be repetitive, so if header name is the key, the value is List<String>. In such case how the values are joined to the single String, what is the separator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will use comma-separated values, as also shown in the picture of the PR description.

}

val requestHeaders = if (includeDefaults) {
(DEFAULT_REQUEST_HEADERS + filteredCustom).distinct()
Copy link
Member

Choose a reason for hiding this comment

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

we can simply use Set then instead of List for the customHeaders property

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe it's useful to keep the order of customHeaders the customer has decided. With a set, we would lose order and still need to deduplicate when joining default and custom headers.

Copy link
Member

Choose a reason for hiding this comment

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

I also have question here, what' the point to keep the order of customer's headers, can you elaborate? also List will allow duplication, which seems not necessary

Copy link
Contributor Author

@kikoveiga kikoveiga Mar 3, 2026

Choose a reason for hiding this comment

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

In cases where the 2 KB limit for all headers might be exceeded, we want to keep first the DEFAULT_HEADERS and then customer's customHeaders. While the default ones are ordered alphabetically, the customer can decide to have some order on the custom ones so they prefer to have more chances of keeping this or that header (even though this is not explicit in the captureHeaders api. If this is not relevant, then yes we could just switch to using a set.

@kikoveiga kikoveiga force-pushed the kikoveiga/RUM-14782/capture-okhttp-network-headers branch 2 times, most recently from 87abd2b to 4fdeb64 Compare March 3, 2026 15:44
@kikoveiga kikoveiga force-pushed the kikoveiga/RUM-14782/capture-okhttp-network-headers branch from 4fdeb64 to a5ccb6e Compare March 3, 2026 16:34
@kikoveiga kikoveiga force-pushed the kikoveiga/RUM-14782/capture-okhttp-network-headers branch from a5ccb6e to 6db4618 Compare March 3, 2026 16:41
0xnm
0xnm previously approved these changes Mar 4, 2026
@kikoveiga kikoveiga force-pushed the kikoveiga/RUM-14782/capture-okhttp-network-headers branch from 202a9b0 to 1cbdfc3 Compare March 4, 2026 14:41
@kikoveiga kikoveiga force-pushed the kikoveiga/RUM-14782/capture-okhttp-network-headers branch 2 times, most recently from 8173492 to b2715fd Compare March 4, 2026 14:56
@kikoveiga kikoveiga force-pushed the kikoveiga/RUM-14782/capture-okhttp-network-headers branch from b2715fd to 70e7274 Compare March 4, 2026 14:58
@kikoveiga kikoveiga requested review from 0xnm and ambushwork March 4, 2026 15:06
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.

4 participants