@@ -52,6 +52,12 @@ public function request(string $method, string $url, array $options = []): Respo
52
52
$ headers ['sentry-trace ' ] = $ parent ->toTraceparent ();
53
53
54
54
$ 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
+ ]);
55
61
56
62
// Check if the request destination is allow listed in the trace_propagation_targets option.
57
63
$ client = $ this ->hub ->getClient ();
@@ -65,14 +71,16 @@ public function request(string $method, string $url, array $options = []): Respo
65
71
66
72
$ options ['headers ' ] = $ headers ;
67
73
68
- $ formattedUri = $ this ->formatUri ($ uri );
69
-
70
74
$ context = new SpanContext ();
71
75
$ context ->setOp ('http.client ' );
72
- $ context ->setDescription ($ method . ' ' . $ formattedUri );
76
+ $ context ->setDescription ($ method . ' ' . ( string ) $ partialUri );
73
77
$ context ->setTags ([
74
78
'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 (),
76
84
]);
77
85
78
86
$ span = $ parent ->startChild ($ context );
@@ -111,10 +119,4 @@ public function setLogger(LoggerInterface $logger): void
111
119
$ this ->client ->setLogger ($ logger );
112
120
}
113
121
}
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
- }
120
122
}
0 commit comments