You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1956c5b
Browse filesBrowse the repository at this point in the historyBrowse files
fix(browser): Apply Http timing attributes to streamed http.client spans (#19643)
This PR fixes a temporary bug in span streaming where we didn't add Http
timing attributes (see
#19613). We can fix
this by following OTels approach:
- delay the ending of `http.client` spans until either 300ms pass by or
we receive the PerformanceResourceTiming entry with the respective
timing information. Of course we end the span with the original
timestamp then.
- Unfortunately, we can only do this for streamed span because
transaction-based spans cannot stay open longer than their parent (e.g.
a pageload or navigation). Otherwise they'd get dropped. So we have to
differentiate between the two modes here (RIP bundle size 😢)
- To ensure we don't flush unnecessarily often, we also now delay
flushing the span buffer for 500ms after a segment span ends. This
slightly changed test semantics in a few integration tests because
manually consecutively segments are now also sent in one envelope. This
is completely fine (actually preferred) because we flush less often
(i.e. fewer requests).
closes#19613
Copy file name to clipboardExpand all lines: dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/http-timings-streamed/test.ts
+2-10Lines changed: 2 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -3,16 +3,8 @@ import { sentryTest } from '../../../../utils/fixtures';
Copy file name to clipboardExpand all lines: dev-packages/browser-integration-tests/suites/tracing/setSpanActive-streamed/nested-parentAlwaysRoot/test.ts
@@ -226,7 +230,7 @@ export function instrumentOutgoingRequests(client: Client, _options?: Partial<Re
226
230
227
231
if(createdSpan){
228
232
if(enableHTTPTimings){
229
-
addHTTPTimings(createdSpan);
233
+
addHTTPTimings(createdSpan,client);
230
234
}
231
235
232
236
onRequestSpanStart?.(createdSpan,{
@@ -237,26 +241,64 @@ export function instrumentOutgoingRequests(client: Client, _options?: Partial<Re
237
241
}
238
242
}
239
243
244
+
/**
245
+
* The maximum time (ms) to wait for PerformanceResourceTiming data before ending the span.
246
+
* Same approach is used by OTel's browser fetch instrumentation:
247
+
* See {@link https://github.com/open-telemetry/opentelemetry-js/blob/30f94fe99339287b1e4d3c8bb90172c2523f06f4/experimental/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L352-L372}
248
+
*/
249
+
constHTTP_TIMING_WAIT_MS=300;
250
+
240
251
/**
241
252
* Creates a temporary observer to listen to the next fetch/xhr resourcing timings,
242
253
* so that when timings hit their per-browser limit they don't need to be removed.
243
254
*
244
255
* @param span A span that has yet to be finished, must contain `url` on data.
0 commit comments