@@ -52,6 +52,12 @@ public function request(string $method, string $url, array $options = []): Respo
5252 $ headers ['sentry-trace ' ] = $ parent ->toTraceparent ();
5353
5454 $ uri = new Uri ($ url );
55+ $ partialUri = Uri::fromParts ([
56+ 'scheme ' => $ uri ->getScheme (),
57+ 'host ' => $ uri ->getHost (),
58+ 'port ' => $ uri ->getPort (),
59+ 'path ' => $ uri ->getPath (),
60+ ]);
5561
5662 // Check if the request destination is allow listed in the trace_propagation_targets option.
5763 $ client = $ this ->hub ->getClient ();
@@ -65,14 +71,16 @@ public function request(string $method, string $url, array $options = []): Respo
6571
6672 $ options ['headers ' ] = $ headers ;
6773
68- $ formattedUri = $ this ->formatUri ($ uri );
69-
7074 $ context = new SpanContext ();
7175 $ context ->setOp ('http.client ' );
72- $ context ->setDescription ($ method . ' ' . $ formattedUri );
76+ $ context ->setDescription ($ method . ' ' . ( string ) $ partialUri );
7377 $ context ->setTags ([
7478 'http.method ' => $ method ,
75- 'http.url ' => $ formattedUri ,
79+ 'http.url ' => (string ) $ partialUri ,
80+ ]);
81+ $ context ->setData ([
82+ 'http.query ' => $ uri ->getQuery (),
83+ 'http.fragment ' => $ uri ->getFragment (),
7684 ]);
7785
7886 $ span = $ parent ->startChild ($ context );
@@ -111,10 +119,4 @@ public function setLogger(LoggerInterface $logger): void
111119 $ this ->client ->setLogger ($ logger );
112120 }
113121 }
114-
115- private function formatUri (Uri $ uri ): string
116- {
117- // Instead of relying on Uri::__toString, we only use a sub set of the URI
118- return Uri::composeComponents ($ uri ->getScheme (), $ uri ->getHost (), $ uri ->getPath (), null , null );
119- }
120122}
0 commit comments