GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(browser): Add `http.response_delivery_type` attribute to resource spans by Lms24 · Pull Request #14056 · getsentry/sentry-javascript

Conversation

@Lms24

@Lms24 Lms24 commented Oct 23, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This PR adds the deliveryType field of a ResourcePeformanceEntry to our resource spans. This attribute can give a definitive answer if a resource was retrieved from the browser cache or if the request was actually made to the resource src.

Unfortunately, deliveryType is not yet supported in all browsers but where it is, it should give us more reliable indicators of browser cache hits/misses.

The alternative way of checking for cache hits/misses (which is to check for transfer and decoded body sizes of a response) has a flaw: It only works for requests to 3rd party origins if that origin returns the Allow-Resource-Timing http header with a matching value. Otherwise, we can't determine the cache hit/miss status for 3rd party requests for certain.

One important thing: The deliveryType value indicating that a request was actually made (i.e. cache miss) is the empty string "". We adjusted Relay to forward empty string values (getsentry/relay#4174) to ensure this value is ingested correctly.

Idea for Product Improvement

Extracted to getsentry/sentry#79651

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Lms24
feat(browser): Add http.response_delivery_type attribute to resourc…
16b21ce
…e spans
@github-actions

github-actions Bot commented Oct 23, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 22.74 KB - -
@sentry/browser - with treeshaking flags 21.53 KB - -
@sentry/browser (incl. Tracing) 35.14 KB +0.05% +17 B 🔺
@sentry/browser (incl. Tracing, Replay) 71.86 KB +0.03% +20 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 62.29 KB +0.03% +16 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 76.17 KB +0.03% +19 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 88.97 KB +0.03% +21 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 90.81 KB +0.02% +15 B 🔺
@sentry/browser (incl. metrics) 26.99 KB - -
@sentry/browser (incl. Feedback) 39.89 KB - -
@sentry/browser (incl. sendFeedback) 27.39 KB - -
@sentry/browser (incl. FeedbackAsync) 32.18 KB - -
@sentry/react 25.5 KB - -
@sentry/react (incl. Tracing) 38.1 KB +0.05% +16 B 🔺
@sentry/vue 26.89 KB - -
@sentry/vue (incl. Tracing) 37.02 KB +0.05% +16 B 🔺
@sentry/svelte 22.88 KB - -
CDN Bundle 24.1 KB - -
CDN Bundle (incl. Tracing) 36.96 KB +0.06% +21 B 🔺
CDN Bundle (incl. Tracing, Replay) 71.62 KB +0.03% +21 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 76.96 KB +0.03% +21 B 🔺
CDN Bundle - uncompressed 70.64 KB - -
CDN Bundle (incl. Tracing) - uncompressed 109.71 KB +0.07% +72 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 222.23 KB +0.04% +72 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 235.45 KB +0.03% +72 B 🔺
@sentry/nextjs (client) 38.18 KB +0.06% +21 B 🔺
@sentry/sveltekit (client) 35.75 KB +0.05% +16 B 🔺
@sentry/node 129.6 KB - -
@sentry/node - without tracing 94.3 KB - -
@sentry/aws-serverless 105.17 KB - -

View base workflow run

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Lms24 Lms24 self-assigned this Oct 23, 2024
Lms24
Lms24 commented Oct 23, 2024
View reviewed changes
Comment thread packages/browser-utils/src/metrics/browserMetrics.ts Outdated
setResourceEntrySizeData(attributes, entry, 'decodedBodySize', 'http.decoded_response_content_length');

if (entry.deliveryType != null) {
attributes['http.response_delivery_type'] = entry.deliveryType || 'default';

@Lms24 Lms24 Oct 23, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm falling back to "default" here because it seems like we drop attributes with empty string values (which is the actual default of the property) during ingest. Ideally we wouldn't need to do this but I don't see a better way at the moment.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

s1gr1d reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@s1gr1d s1gr1d Oct 23, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add an explaining comment to the code why this is needed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Lms24 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@Lms24
add integration test for empty string attribute
b176f1d
@Lms24
Lms24 requested review from AbhiPrasad and s1gr1d October 23, 2024 08:51
@Lms24
fix tests
9620908
s1gr1d
s1gr1d approved these changes Oct 23, 2024
View reviewed changes

@s1gr1d s1gr1d left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/browser-utils/src/metrics/browserMetrics.ts Outdated
setResourceEntrySizeData(attributes, entry, 'decodedBodySize', 'http.decoded_response_content_length');

if (entry.deliveryType != null) {
attributes['http.response_delivery_type'] = entry.deliveryType || 'default';

@s1gr1d s1gr1d Oct 23, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add an explaining comment to the code why this is needed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Lms24 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
AbhiPrasad
AbhiPrasad approved these changes Oct 23, 2024
View reviewed changes
@Dhrumil-Sentry Dhrumil-Sentry mentioned this pull request Oct 23, 2024
Helps users quickly understand if a resource script was loaded from a cache or not getsentry/sentry#79651
Open
@Lms24
add comment
d8feca0
@Lms24

Lms24 commented Oct 24, 2024

Copy link
Copy Markdown
Member Author

Thx for the reviews! I added a comment in the code as to why I add default as a fallback value. However, I'm gonna hold off from merging this PR because it seems like empty string values should actually be allowed (at least during ingest). If it turns out we can fix this product-side, I'd like to avoid adding "default" but simply forward the empty string to stay consistent with what the browser hands to us.

s1gr1d reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Lms24

Lms24 commented Oct 28, 2024

Copy link
Copy Markdown
Member Author

Gonna hold off from merging this until getsentry/relay#4174 is out. I think it's way better for us to forward the empty string value instead if "default", so it makes sense to wait on this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Lms24
switch to empty string as default value
595f2d3
@Lms24

Lms24 commented Oct 31, 2024

Copy link
Copy Markdown
Member Author

getsentry/relay#4174 is merged and deployed so we can merge this PR now 🎉

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Lms24
Lms24 enabled auto-merge (squash) October 31, 2024 11:37
@Lms24
Lms24 merged commit d2a9826 into develop Oct 31, 2024
@Lms24
Lms24 deleted the lms/feat-resource-deliverytype branch October 31, 2024 11:46
@Lms24 Lms24 mentioned this pull request Sep 8, 2025
Populate attribute that indicates whether resource spans were served from cache #15762
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@s1gr1d s1gr1d s1gr1d approved these changes
+1 more reviewer
@AbhiPrasad AbhiPrasad AbhiPrasad approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@Lms24 Lms24

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Lms24 @AbhiPrasad @s1gr1d
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.