-
Notifications
You must be signed in to change notification settings - Fork 179
fix: Sanatize HTTP client spans #690
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
Conversation
private function formatUri(Uri $uri): string | ||
{ | ||
// Instead of relying on Uri::__toString, we only use a sub set of the URI | ||
return Uri::composeComponents($uri->getScheme(), $uri->getHost(), $uri->getPath(), null, null); |
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.
The signature is Uri::composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment)
, so I feel like this was implemented in a wrong way.
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.
Since it's almost an internal method I think they chose not to bother with default arguments. It's also not part of the PSR-7 spec: https://www.php-fig.org/psr/psr-7/.
$partialUri = Uri::fromParts([ | ||
'scheme' => $uri->getScheme(), | ||
'host' => $uri->getHost(), | ||
'port' => $uri->getPort(), | ||
'path' => $uri->getPath(), | ||
]); |
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.
CS seems off here:
$partialUri = Uri::fromParts([ | |
'scheme' => $uri->getScheme(), | |
'host' => $uri->getHost(), | |
'port' => $uri->getPort(), | |
'path' => $uri->getPath(), | |
]); | |
$partialUri = Uri::fromParts([ | |
'scheme' => $uri->getScheme(), | |
'host' => $uri->getHost(), | |
'port' => $uri->getPort(), | |
'path' => $uri->getPath(), | |
]); |
And:
l
: The only "worry" I have here is that a MalformedUriException
is thrown for some reason. Although this might be totally unfounded since a URI was already there but maybe we want to try/catch anyway just to be 100% sure since not all PSR-7's might be created equal.
private function formatUri(Uri $uri): string | ||
{ | ||
// Instead of relying on Uri::__toString, we only use a sub set of the URI | ||
return Uri::composeComponents($uri->getScheme(), $uri->getHost(), $uri->getPath(), null, null); |
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.
Since it's almost an internal method I think they chose not to bother with default arguments. It's also not part of the PSR-7 spec: https://www.php-fig.org/psr/psr-7/.
See https://develop.sentry.dev/sdk/data-handling/#spans & https://develop.sentry.dev/sdk/data-handling/#breadcrumbs.
refs: getsentry/team-webplatform-meta#2