RUM-13141: Add integration test for OkHttp resource timing feature#3428
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1ac1acc736
ℹ️ 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".
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3428 +/- ##
===========================================
- Coverage 72.08% 72.03% -0.04%
===========================================
Files 961 961
Lines 35418 35418
Branches 5883 5883
===========================================
- Hits 25528 25513 -15
- Misses 8279 8287 +8
- Partials 1611 1618 +7 🚀 New features to boost your workflow:
|
1ac1acc to
ae32359
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Wires DatadogInterceptor and DatadogEventListener.Factory on a real OkHttpClient against a MockWebServer and asserts the RUM resource event JSON carries the timing breakdown sub-objects (dns / connect / first_byte / download). Covers the integration that unit tests cannot reach: the interceptor and the listener must agree on the ResourceId derived from the request tag for timings to reach the correct resource scope, and concurrent requests to the same URL must remain isolated. Test cases: - single HTTP request populates the full timing breakdown - HTTP >= 400 still produces timings via the early-flush path in responseHeadersEnd - a dropped socket produces a RUM error event (not a resource event) with error.resource populated - five concurrent requests to the same URL each produce an isolated resource event with its own timing breakdown
ae32359 to
22d4d44
Compare
| } | ||
|
|
||
| @AfterEach | ||
| fun `tear down`() { |
There was a problem hiding this comment.
minor: it is probably worth to clean up GlobalRumMonitor as well (reflection will be needed)
it is not done in other similar tests, so probably not a big deal (we are just leaving fake values in the static property after the test).
Pin asserted URLs to the full request URL via mockServer.url(path) rather than checking only that the hostname is present. Deserialize the network-failure error event into a typed ErrorEvent model so field access is type-checked instead of navigating raw JSON. Use executor.execute in the concurrent test since the returned Future was unused and submit silently swallows uncaught exceptions.
…y/okhttp tests Datadog.stopInstance only triggers RumFeature.onStop (which in turn calls GlobalRumMonitor.unregister) for real DatadogCore instances. With a StubSDKCore the cast fails silently and the monitor entry leaks into the static registry for the rest of the JVM. Add a shared reliability-test helper that mutates GlobalRumMonitor.registeredMonitors via field reflection, and call it from @AfterEach in every reliability/okhttp test that uses StubSDKCore. Field-based reflection is used because GlobalRumMonitor.unregister is internal and its JVM name is mangled with the SDK module suffix; the private map field name is stable.
What does this PR do?
Adds an end-to-end integration test,
ResourceTimingIntegrationTest, underreliability/single-fit/okhttp. The test wiresDatadogInterceptorandDatadogEventListener.Factoryon a realOkHttpClientagainst aMockWebServerand asserts that RUM resource events carry the timing breakdown sub-objects (dns/connect/first_byte/download).Four cases:
sslsection.DatadogEventListener.responseHeadersEnd.SocketPolicy.DISCONNECT_AT_START) produces a RUM error event (not a resource event) witherror.resource.urlpopulated.Motivation
The interceptor and the listener are independent OkHttp components that must agree on the
ResourceIdderived from the request tag for timing events to reach the correct resource scope. They also need to remain isolated under concurrent requests to the same URL. Both behaviors live at the integration seam and are not exercised by the existing unit tests of either component (which mock theGlobalRumMonitor). Past regressions in this area went out unnoticed; this test closes that coverage gap.Review checklist (to be filled by reviewers)