Skip to content

feat(tracing): add body size for fetch requests #7935

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 3, 2023

Conversation

DominikB2014
Copy link
Contributor

@DominikB2014 DominikB2014 commented Apr 21, 2023

Drafting this for now, after discussing this, we couldn't find a way to get body size easily from the performance timing api, so instead we're retrieving this from the content-length header, this represents the body size of the encoded response.
We already document the encoded body size, so I decided to reuse that name as to not cause confusion.

@DominikB2014 DominikB2014 requested a review from AbhiPrasad April 21, 2023 17:53
@github-actions
Copy link
Contributor

github-actions bot commented Apr 21, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 21.02 KB (-0.01% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 65.66 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 19.56 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified) 58.12 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 21.17 KB (0%)
@sentry/browser - Webpack (minified) 69.07 KB (0%)
@sentry/react - Webpack (gzipped + minified) 21.19 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 49.09 KB (+0.11% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 28.65 KB (+0.17% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 26.87 KB (+0.17% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 46.87 KB (+0.15% 🔺)
@sentry/replay - Webpack (gzipped + minified) 40.67 KB (+0.19% 🔺)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 65.75 KB (+0.19% 🔺)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 58.64 KB (+0.13% 🔺)

@@ -195,6 +197,7 @@ export function fetchCallback(
data: {
...handlerData.fetchData,
type: 'fetch',
...(contentLength ? { 'Encoded Body Size': contentLength } : {}),
Copy link
Member

Choose a reason for hiding this comment

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

h: I actually think we should try and deprecate and move away from Encoded Body Size - having a key with capitals + spaces seems like an anti-pattern, can we try to rename this and update the sentry code accordingly?

Copy link
Member

Choose a reason for hiding this comment

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

@AbhiPrasad Is there a convention for params like this? camel/snake case? I'm taking over the rollout of this perf issue so I'll make the changes

Copy link
Member

Choose a reason for hiding this comment

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

https://develop.sentry.dev/sdk/performance/span-data-conventions/ is the list.

Keys on the data field should be lower-case and use underscores instead of camel-case. There are some exceptions to this, but these exist because of backwards compatibility.

. separators are also used.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I made a change to switch to encoded_body_size here, but I noticed that other perf issues also depend on values in this data object such as "Transfer Size", "Encoded Body Size", and "Decoded Body Size". Do you know if these keys would count as exceptions to the rule? It feels like renaming here would be inconsistent

Copy link
Member

Choose a reason for hiding this comment

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

those keys would be exceptions - and we would update the develop docs accordingly.

Ideally all sentry code would update to reference and use the new keys cc @k-fish.

Copy link
Member

Choose a reason for hiding this comment

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

No perf detector should depend on it atm

I was mistaken here - I thought the perf detectors would restrict to resource spans since that only sends data atm, but from reading source code I guess http works as well.

Copy link
Member

Choose a reason for hiding this comment

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

also @AbhiPrasad I don't think we ever changed to snake_case we just talked about it right? it's bothered me as well but I'm not sure we made plans to change encoded/decoded to snake yet.. or did we and I forget?

Copy link
Member

Choose a reason for hiding this comment

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

otel now uses snake case so I think we try and match that (for ex: https://github.com/open-telemetry/opentelemetry-specification/pull/3287/files).

Copy link
Member

Choose a reason for hiding this comment

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

Also, should it be http.response_content_length? That seems to be what OTel is suggesting

Copy link
Member

Choose a reason for hiding this comment

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

yeah @gggritso that makes sense to me. @narsaynorath could we first open a PR on develop to https://github.com/getsentry/develop to establish the naming, and then update both sentry/sdks?

narsaynorath added a commit to getsentry/sentry that referenced this pull request Apr 27, 2023
…47830)

Replaces usages of "Encoded Body Size", "Decoded Body Size", "Transfer
Size" with their snake case counterparts. This is for standardizing with
OTel formatting in SDKs.

Motivating discussion:
getsentry/sentry-javascript#7935 (comment)
@narsaynorath narsaynorath marked this pull request as ready for review April 27, 2023 20:54
@narsaynorath narsaynorath requested a review from AbhiPrasad April 27, 2023 20:54
@AbhiPrasad
Copy link
Member

@narsaynorath reminder we squash merge all of our commits!

@narsaynorath
Copy link
Member

Hey @AbhiPrasad, were there any other changes you needed from me here?

@AbhiPrasad
Copy link
Member

Looks like we need to fix some conflicts, then we should be good to go to merge.

@AbhiPrasad AbhiPrasad changed the title add body size for fetch requests feat(tracing): add body size for fetch requests May 2, 2023
@AbhiPrasad
Copy link
Member

Our CI is broken - please bear with us while we fix. I can take care of merging this in after we do that!

@AbhiPrasad
Copy link
Member

Took the liberty to update to develop and change a test - will merge in!

@AbhiPrasad AbhiPrasad enabled auto-merge (squash) May 3, 2023 10:59
@AbhiPrasad AbhiPrasad merged commit f08811e into develop May 3, 2023
@AbhiPrasad AbhiPrasad deleted the DominikB2014/add-body-size branch May 3, 2023 11:15
billyvg pushed a commit that referenced this pull request May 5, 2023
Co-authored-by: Nar Saynorath <nar.saynorath@sentry.io>
Co-authored-by: Abhijeet Prasad <aprasad@sentry.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants