Skip to content
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

feat(core): Add server.address to browser http.client spans #11634

Merged
merged 6 commits into from
Apr 17, 2024

Conversation

mydea
Copy link
Member

@mydea mydea commented Apr 16, 2024

Closes #11632

@mydea mydea requested review from gggritso and AbhiPrasad April 16, 2024 14:53
@mydea mydea self-assigned this Apr 16, 2024
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Can we update the tests for this as well?

Copy link
Contributor

github-actions bot commented Apr 16, 2024

size-limit report 📦

Path Size
@sentry/browser 21.67 KB (0%)
@sentry/browser (incl. Tracing) 31.39 KB (+0.37% 🔺)
@sentry/browser (incl. Tracing, Replay) 66.71 KB (+0.19% 🔺)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 60.12 KB (+0.22% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) 70.55 KB (+0.17% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) 80.41 KB (+0.16% 🔺)
@sentry/browser (incl. Feedback) 35.25 KB (0%)
@sentry/browser (incl. Feedback, Feedback Modal) 35.25 KB (0%)
@sentry/browser (incl. Feedback, Feedback Modal, Feedback Screenshot) 37.28 KB (0%)
@sentry/browser (incl. sendFeedback) 26.46 KB (0%)
@sentry/react 24.35 KB (0%)
@sentry/react (incl. Tracing) 34.3 KB (+0.37% 🔺)
@sentry/vue 25.2 KB (0%)
@sentry/vue (incl. Tracing) 33.11 KB (+0.36% 🔺)
@sentry/svelte 21.79 KB (0%)
CDN Bundle 24.03 KB (0%)
CDN Bundle (incl. Tracing) 32.69 KB (+0.34% 🔺)
CDN Bundle (incl. Tracing, Replay) 66.32 KB (+0.16% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) 82.53 KB (+0.15% 🔺)
CDN Bundle - uncompressed 70.86 KB (0%)
CDN Bundle (incl. Tracing) - uncompressed 97.37 KB (+0.4% 🔺)
CDN Bundle (incl. Tracing, Replay) - uncompressed 207.03 KB (+0.19% 🔺)
@sentry/nextjs (client) 33.63 KB (+0.35% 🔺)
@sentry/sveltekit (client) 31.89 KB (+0.39% 🔺)
@sentry/node 153.46 KB (-0.01% 🔽)

@mydea
Copy link
Member Author

mydea commented Apr 16, 2024

Can we update the tests for this as well?

Good point, was surprised we have nothing for this actually, I added tests to ensure we check the span data for the important stuff at least :)

@mydea mydea force-pushed the fn/add-server-request branch from 5642fad to c4a5142 Compare April 16, 2024 15:17
@mydea
Copy link
Member Author

mydea commented Apr 16, 2024

OK, after @gggritso's comment I actually added tests for relative URLs, which showed the initial implementation was flawed! Now it should work - it's a bit more complicated because for the base fetch instrumentation, we can't access window.location (because it's isomorphic), so I update it for browser specifically and have a generic implementation in core without that.

const host = parseUrl(fullUrl).host;
createdSpan.setAttributes({
'http.url': fullUrl,
'server.address': host,
Copy link
Member

Choose a reason for hiding this comment

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

A small ask, but could you add server.port, too while you're here? It'd made life a lot easier in Relay when creating span metrics tags!

Copy link
Member Author

Choose a reason for hiding this comment

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

sadly it's not so easy to get the port, as most URLs don't have it and we just don't really know. We could "guess" it based on the protocol but this seems tricky to me? Anyhow, we can track this in a separate issue if we need this, I'd say!

@@ -76,6 +76,8 @@ test('Should trace outgoing fetch requests inside middleware and create breadcru
'http.response.status_code': 200,
type: 'fetch',
url: 'http://localhost:3030/',
'http.url': 'http://localhost:3030/',
'server.address': 'localhost:3030',
Copy link
Member Author

Choose a reason for hiding this comment

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

@gggritso regarding port, you can see here that the port is part of the server.address if it is in the URL (=non-standard)

Copy link
Member

Choose a reason for hiding this comment

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

Roger, thanks!

@mydea mydea merged commit daf2edf into develop Apr 17, 2024
96 checks passed
@mydea mydea deleted the fn/add-server-request branch April 17, 2024 07:57
AbhiPrasad added a commit that referenced this pull request Apr 18, 2024
…11663)

Backport of #11634 to
v7

---------

Co-authored-by: Francesco Novy <francesco.novy@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.

Add server.address attribute to http.client spans
4 participants