Skip to content

Commit ed34b0c

Browse files
authored
Remove support for traceparent (#928)
1 parent 58bbad0 commit ed34b0c

File tree

8 files changed

+9
-94
lines changed

8 files changed

+9
-94
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"php": "^7.2||^8.0",
1616
"guzzlehttp/psr7": "^2.1.1",
1717
"jean85/pretty-package-versions": "^1.5||^2.0",
18-
"sentry/sentry": "^4.11.0",
18+
"sentry/sentry": "^4.14.1",
1919
"symfony/cache-contracts": "^1.1||^2.4||^3.0",
2020
"symfony/config": "^4.4.20||^5.0.11||^6.0||^7.0",
2121
"symfony/console": "^4.4.20||^5.0.11||^6.0||^7.0",

src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV2V3.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ private function traceFunction(string $spanOperation, string $spanDescription, \
246246
*
247247
* @param array<string, mixed> $params The connection params
248248
*
249-
* @return array<string, string>
250-
*
251249
* @phpstan-param ConnectionParams $params
252250
*
251+
* @return array<string, string>
252+
*
253253
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/database.md
254254
*/
255255
private function getSpanData(string $databasePlatform, array $params): array

src/Tracing/Doctrine/DBAL/TracingDriverConnectionForV4.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ private function traceFunction(string $spanOperation, string $spanDescription, \
244244
*
245245
* @param array<string, mixed> $params The connection params
246246
*
247-
* @return array<string, string>
248-
*
249247
* @phpstan-param ConnectionParams $params
250248
*
249+
* @return array<string, string>
250+
*
251251
* @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/database.md
252252
*/
253253
private function getSpanData(string $databasePlatform, array $params): array

src/Tracing/HttpClient/AbstractTraceableHttpClient.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
use function Sentry\getBaggage;
2020
use function Sentry\getTraceparent;
21-
use function Sentry\getW3CTraceparent;
2221

2322
/**
2423
* This is an implementation of the {@see HttpClientInterface} that decorates
@@ -59,7 +58,6 @@ public function request(string $method, string $url, array $options = []): Respo
5958
if (self::shouldAttachTracingHeaders($client, $uri)) {
6059
$headers['baggage'] = getBaggage();
6160
$headers['sentry-trace'] = getTraceparent();
62-
$headers['traceparent'] = getW3CTraceparent();
6361
}
6462

6563
$options['headers'] = $headers;

src/Twig/SentryExtension.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use function Sentry\getBaggage;
1212
use function Sentry\getTraceparent;
13-
use function Sentry\getW3CTraceparent;
1413

1514
final class SentryExtension extends AbstractExtension
1615
{
@@ -43,10 +42,12 @@ public function getTraceMeta(): string
4342

4443
/**
4544
* Returns an HTML meta tag named `traceparent`.
45+
*
46+
* @deprecated since version 5.3. To be removed in version 6.0.
4647
*/
4748
public function getW3CTraceMeta(): string
4849
{
49-
return \sprintf('<meta name="traceparent" content="%s" />', getW3CTraceparent());
50+
return '';
5051
}
5152

5253
/**

tests/EventListener/TracingRequestListenerTest.php

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -129,45 +129,6 @@ public function handleKernelRequestEventDataProvider(): \Generator
129129
$transactionContext,
130130
];
131131

132-
$samplingContext = DynamicSamplingContext::fromHeader('');
133-
$samplingContext->freeze();
134-
135-
$transactionContext = new TransactionContext();
136-
$transactionContext->setTraceId(new TraceId('566e3688a61d4bc888951642d6f14a19'));
137-
$transactionContext->setParentSpanId(new SpanId('566e3688a61d4bc8'));
138-
$transactionContext->setParentSampled(true);
139-
$transactionContext->setName('GET http://www.example.com/');
140-
$transactionContext->setSource(TransactionSource::url());
141-
$transactionContext->setOp('http.server');
142-
$transactionContext->setOrigin('auto.http.server');
143-
$transactionContext->setStartTimestamp(1613493597.010275);
144-
$transactionContext->setData([
145-
'net.host.port' => '80',
146-
'http.request.method' => 'GET',
147-
'http.url' => 'http://www.example.com/',
148-
'http.flavor' => '1.1',
149-
'route' => '<unknown>',
150-
'net.host.name' => 'www.example.com',
151-
]);
152-
$transactionContext->getMetadata()->setDynamicSamplingContext($samplingContext);
153-
$transactionContext->getMetadata()->setSampleRand(0.1337);
154-
155-
yield 'request.headers.traceparent EXISTS' => [
156-
new Options(),
157-
Request::create(
158-
'http://www.example.com',
159-
'GET',
160-
[],
161-
[],
162-
[],
163-
[
164-
'REQUEST_TIME_FLOAT' => 1613493597.010275,
165-
'HTTP_traceparent' => '00-566e3688a61d4bc888951642d6f14a19-566e3688a61d4bc8-01',
166-
]
167-
),
168-
$transactionContext,
169-
];
170-
171132
$samplingContext = DynamicSamplingContext::fromHeader('sentry-trace_id=566e3688a61d4bc888951642d6f14a19,sentry-public_key=public,sentry-sample_rate=1');
172133
$samplingContext->freeze();
173134

tests/Tracing/HttpClient/TraceableHttpClientTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function testRequestDoesContainsTracingHeadersWithoutTransaction(): void
176176
'trace_propagation_targets' => ['www.example.com'],
177177
]);
178178
$client = $this->createMock(ClientInterface::class);
179-
$client->expects($this->exactly(5))
179+
$client->expects($this->exactly(4))
180180
->method('getOptions')
181181
->willReturn($options);
182182

@@ -200,7 +200,6 @@ public function testRequestDoesContainsTracingHeadersWithoutTransaction(): void
200200
$this->assertSame('POST', $response->getInfo('http_method'));
201201
$this->assertSame('https://www.example.com/test-page', $response->getInfo('url'));
202202
$this->assertSame([\sprintf('sentry-trace: %s', $propagationContext->toTraceparent())], $mockResponse->getRequestOptions()['normalized_headers']['sentry-trace']);
203-
$this->assertSame([\sprintf('traceparent: %s', $propagationContext->toW3CTraceparent())], $mockResponse->getRequestOptions()['normalized_headers']['traceparent']);
204203
$this->assertSame([\sprintf('baggage: %s', $propagationContext->toBaggage())], $mockResponse->getRequestOptions()['normalized_headers']['baggage']);
205204
}
206205

tests/Twig/SentryExtensionTest.php

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -73,50 +73,6 @@ public function testTraceMetaFunctionWithActiveSpan(): void
7373
$this->assertSame('<meta name="sentry-trace" content="a3c01c41d7b94b90aee23edac90f4319-e69c2aef0ec34f2a-1" />', $environment->render('foo.twig'));
7474
}
7575

76-
public function testW3CTraceMetaFunctionWithNoActiveSpan(): void
77-
{
78-
$environment = new Environment(new ArrayLoader(['foo.twig' => '{{ sentry_w3c_trace_meta() }}']));
79-
$environment->addExtension(new SentryExtension());
80-
81-
$propagationContext = PropagationContext::fromDefaults();
82-
$propagationContext->setTraceId(new TraceId('566e3688a61d4bc888951642d6f14a19'));
83-
$propagationContext->setSpanId(new SpanId('566e3688a61d4bc8'));
84-
85-
$hub = new Hub(null, new Scope($propagationContext));
86-
87-
SentrySdk::setCurrentHub($hub);
88-
89-
$this->assertSame('<meta name="traceparent" content="00-566e3688a61d4bc888951642d6f14a19-566e3688a61d4bc8-00" />', $environment->render('foo.twig'));
90-
}
91-
92-
public function testW3CTraceMetaFunctionWithActiveSpan(): void
93-
{
94-
$environment = new Environment(new ArrayLoader(['foo.twig' => '{{ sentry_w3c_trace_meta() }}']));
95-
$environment->addExtension(new SentryExtension());
96-
97-
$client = $this->createMock(ClientInterface::class);
98-
$client->expects($this->atLeastOnce())
99-
->method('getOptions')
100-
->willReturn(new Options([
101-
'traces_sample_rate' => 1.0,
102-
'release' => '1.0.0',
103-
'environment' => 'development',
104-
]));
105-
106-
$hub = new Hub($client);
107-
108-
SentrySdk::setCurrentHub($hub);
109-
110-
$transaction = new Transaction(new TransactionContext());
111-
$transaction->setTraceId(new TraceId('a3c01c41d7b94b90aee23edac90f4319'));
112-
$transaction->setSpanId(new SpanId('e69c2aef0ec34f2a'));
113-
$transaction->setSampled(true);
114-
115-
$hub->setSpan($transaction);
116-
117-
$this->assertSame('<meta name="traceparent" content="00-a3c01c41d7b94b90aee23edac90f4319-e69c2aef0ec34f2a-01" />', $environment->render('foo.twig'));
118-
}
119-
12076
public function testBaggageMetaFunctionWithNoActiveSpan(): void
12177
{
12278
$environment = new Environment(new ArrayLoader(['foo.twig' => '{{ sentry_baggage_meta() }}']));

0 commit comments

Comments
 (0)