Conversation
AbhiPrasad
approved these changes
Sep 9, 2025
Lms24
added a commit
to getsentry/sentry-javascript
that referenced
this pull request
Sep 12, 2025
…17562) Adds a few attributes to `resource.*` spans for request timing and status information. Most importantly: - `http.request.time_to_first_byte` [from `responseStart`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/responseStart) which can be [interpreted as TTFB](https://web.dev/articles/ttfb#measure-resource-requests) for resource requests. This was requested via via getsentry/sentry#63739. - `http.response.status_code` the status code of the resource request. Requested in #16805 and #10995 To get these attributes, I adjusted the already existing `resourceTimingToSpanAttributes` a bit: - Moved it from browser to browser-utils because resource spans logic is located in browser-utils (this is safe, it never was exported from browser) - Changed the signature to return an object instead of an array of attributes. This is more ergonomical to use in both callsites and should reduce bundle size slightly - Added `http.request.redirect_end`, `http.request.worker_start` attributes which are stable timing values available on `PerformanceResourceTiming` but were previously missing - Also added to conventions: getsentry/sentry-conventions#130 - Added `http.request.time_to_first_byte`. Decided to add this attribute because `http.request.response_start` cannot be directly used as TTFB as its value is an absolute time stamp of `responseStart`. Instead the TTFB attribute is the relative response start attribute converted to seconds (happy to change to ms if reviewers prefer). - Also added to conventions: getsentry/sentry-conventions#131 Other consequences: - `http.client` spans now also have the three additional attributes Remarks: - Not super happy about us always defaulting to `0` in case a value is not present. But decided to leave this as-is to avoid any behaviour change for http.client spans.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds the following attributes:
http.request.worker_starthttp.request.redirect_endwhich are timestamps in the browsers request lifecycle model but were missing from our conventions.
These attributes will be collected from to the browser JS SDK once getsentry/sentry-javascript#17562 is merged.
Note: I realized a lot of other request timing values are marked as
type: integer. However, the browser SDK returns floating point numbers (milliseconds divided by 1000), so I think they should rather betype: double. Will open a separate PR with fixes.