RUM-14782: Capture OkHttp Network Headers#3204
Conversation
4ed9e06 to
a082ecb
Compare
This comment has been minimized.
This comment has been minimized.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #3204 +/- ##
===========================================
+ Coverage 71.29% 71.38% +0.09%
===========================================
Files 938 940 +2
Lines 34667 34764 +97
Branches 5874 5893 +19
===========================================
+ Hits 24715 24814 +99
+ Misses 8305 8298 -7
- Partials 1647 1652 +5
🚀 New features to boost your workflow:
|
998a873 to
789aef2
Compare
d99452e to
de59997
Compare
There was a problem hiding this comment.
💡 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".
de59997 to
8aed174
Compare
| const val GRAPHQL_ERRORS: String = "_dd.graphql.errors" | ||
|
|
||
| /** | ||
| * The request headers of the resource. (Map<String, String>) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
We will use comma-separated values, as also shown in the picture of the PR description.
87abd2b to
4fdeb64
Compare
4fdeb64 to
a5ccb6e
Compare
There was a problem hiding this comment.
0758bf7 to
58e640a
Compare
| getBodyLength(response, sdkCore.internalLogger), | ||
| kind, | ||
| attributes + rumResourceAttributesProvider.onProvideAttributes(request, response, null) | ||
| attributes + headerAttributes + rumResourceAttributesProvider.onProvideAttributes(request, response, null) |
There was a problem hiding this comment.
onProvideAttributes functions allows to return Map<String, Any?>, but in RumResourceScope you try to cast it to Map<String,String> with as?, what will happen if the client implements rumResourceAttributesProvider but returns different stuff than Map<String,String>?
There was a problem hiding this comment.
So does it make sense to change the order of the + here?
rumResourceAttributesProvider.onProvideAttributes(request, response, null) + attributes + headerAttributes
This is lowest to highest priority (left to right):
- Customer attributes — can be overridden by everything
- Trace/GraphQL attributes — SDK internals override customer if conflict
- Header attributes — always win, since the SDK controls these keys entirely
There was a problem hiding this comment.
yes, it's safer to put headerAttributes in the end to protect our header attributes not overwritten by user. also we need unit tests for this corner case.
There was a problem hiding this comment.
Moved to the end for now.
There was a problem hiding this comment.
As I mentioned a unit test is needed here, because this behavior can be easily broken by changing the order, so this unit test should:
- fail - when the order is
attributes + headerAttributes + rumResourceAttributesProvider.onProvideAttributes(request, response, null) - succeed - when the order is
attributes + rumResourceAttributesProvider.onProvideAttributes(request, response, null) + headerAttributes
There was a problem hiding this comment.
Added a test in the end of DatadogInterceptorTest, thank you!
453aba5 to
3806db0
Compare
094b22f to
2dbb2d2
Compare
2dbb2d2 to
cb15ea2
Compare
… ResourceHeadersExtractor
67f72b4 to
ca764ab
Compare
ca764ab to
ba09435
Compare
What does this PR do?
trackResourceHeaderspublic api inDatadogInterceptor.RumAttributes.RumResourceScopeand add them to theresource.ResourceHeadersExtractor.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:
This is aligned with the iOS implementation:
Review checklist (to be filled by reviewers)