From d497c9b493b3a26f2cb37a1a646b3285d220a0f5 Mon Sep 17 00:00:00 2001 From: k-fish Date: Fri, 14 Jul 2023 11:53:09 -0400 Subject: [PATCH] feat(tracing): Add more network timings to http calls There are enough now that we'll have to hide some in the UI, but we should be collecting all of these so we can better determine reasons for initial request delay. --- .../tracing/browsertracing/http-timings/test.ts | 7 +++++++ packages/tracing-internal/src/browser/request.ts | 13 ++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/http-timings/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/http-timings/test.ts index c4b5d3e92e62..566c14297897 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/http-timings/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/http-timings/test.ts @@ -40,9 +40,16 @@ sentryTest('should create fetch spans with http timing', async ({ browserName, g timestamp: expect.any(Number), trace_id: tracingEvent.contexts?.trace?.trace_id, data: expect.objectContaining({ + 'http.request.redirect_start': expect.any(Number), + 'http.request.fetch_start': expect.any(Number), + 'http.request.domain_lookup_start': expect.any(Number), + 'http.request.domain_lookup_end': expect.any(Number), 'http.request.connect_start': expect.any(Number), + 'http.request.secure_connection_start': expect.any(Number), + 'http.request.connection_end': expect.any(Number), 'http.request.request_start': expect.any(Number), 'http.request.response_start': expect.any(Number), + 'http.request.response_end': expect.any(Number), 'network.protocol.version': expect.any(String), }), }), diff --git a/packages/tracing-internal/src/browser/request.ts b/packages/tracing-internal/src/browser/request.ts index 071b2146bb16..28efe77d4b99 100644 --- a/packages/tracing-internal/src/browser/request.ts +++ b/packages/tracing-internal/src/browser/request.ts @@ -195,9 +195,16 @@ function resourceTimingEntryToSpanData(resourceTiming: PerformanceResourceTiming } return [ ...timingSpanData, - ['http.request.connect_start', (browserPerformanceTimeOrigin + resourceTiming.connectStart) / 1000], - ['http.request.request_start', (browserPerformanceTimeOrigin + resourceTiming.requestStart) / 1000], - ['http.request.response_start', (browserPerformanceTimeOrigin + resourceTiming.responseStart) / 1000], + ['http.request.redirect_start', resourceTiming.redirectStart], + ['http.request.fetch_start', resourceTiming.fetchStart], + ['http.request.domain_lookup_start', resourceTiming.domainLookupStart], + ['http.request.domain_lookup_end', resourceTiming.domainLookupEnd], + ['http.request.connect_start', resourceTiming.connectStart], + ['http.request.secure_connection_start', resourceTiming.secureConnectionStart], + ['http.request.connection_end', resourceTiming.connectEnd], + ['http.request.request_start', resourceTiming.requestStart], + ['http.request.response_start', resourceTiming.responseStart], + ['http.request.response_end', resourceTiming.responseEnd], ]; }