Skip to content

Commit 990d5a4

Browse files
committed
update AbstractTraceableHttpClient to include the baggage header on Symfony HTTP Client requests
1 parent 072c454 commit 990d5a4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Tracing/HttpClient/AbstractTraceableHttpClient.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Sentry\SentryBundle\Tracing\HttpClient;
66

7+
use GuzzleHttp\Psr7\Uri;
78
use Psr\Log\LoggerAwareInterface;
89
use Psr\Log\LoggerInterface;
910
use Sentry\State\HubInterface;
@@ -49,6 +50,18 @@ public function request(string $method, string $url, array $options = []): Respo
4950
if (null !== $parent) {
5051
$headers = $options['headers'] ?? [];
5152
$headers['sentry-trace'] = $parent->toTraceparent();
53+
54+
// Check if the request destination is allow listed in the trace_propagation_targets option.
55+
$client = $this->hub->getClient();
56+
if (null !== $client) {
57+
$sdkOptions = $client->getOptions();
58+
$uri = new Uri($url);
59+
60+
if (\in_array($uri->getHost(), $sdkOptions->getTracePropagationTargets())) {
61+
$headers['baggage'] = $parent->toBaggage();
62+
}
63+
}
64+
5265
$options['headers'] = $headers;
5366

5467
$context = new SpanContext();

0 commit comments

Comments
 (0)