Skip to content

Commit 51daae7

Browse files
committed
Make the TracingController emit a trace anyway
1 parent 4b5ea8a commit 51daae7

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

tests/End2End/App/Controller/TracingController.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,48 @@
55
namespace Sentry\SentryBundle\Tests\End2End\App\Controller;
66

77
use Doctrine\DBAL\Connection;
8+
use Sentry\State\HubInterface;
9+
use Sentry\Tracing\SpanContext;
810
use Symfony\Component\HttpFoundation\Response;
911

1012
class TracingController
1113
{
14+
/**
15+
* @var HubInterface
16+
*/
17+
private $hub;
18+
1219
/**
1320
* @var Connection|null
1421
*/
1522
private $connection;
1623

17-
public function __construct(Connection $connection = null)
24+
public function __construct(HubInterface $hub, Connection $connection = null)
1825
{
26+
$this->hub = $hub;
1927
$this->connection = $connection;
2028
}
2129

2230
public function pingDatabase(): Response
2331
{
32+
$this->hub->setSpan(
33+
$this->hub->getSpan()
34+
->startChild($this->createSpan())
35+
);
36+
2437
if ($this->connection) {
2538
$this->connection->executeQuery('SELECT 1');
2639
}
2740

2841
return new Response('Success');
2942
}
43+
44+
private function createSpan(): SpanContext
45+
{
46+
$spanContext = new SpanContext();
47+
$spanContext->setOp('mock.span');
48+
$spanContext->setDescription('mocked subspan');
49+
50+
return $spanContext;
51+
}
3052
}

tests/End2End/App/tracing.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ sentry:
66

77
services:
88
Sentry\SentryBundle\Tests\End2End\App\Controller\TracingController:
9+
autowire: true
910
arguments:
10-
- '@?doctrine.dbal.default_connection'
11+
$connection: '@?doctrine.dbal.default_connection'
1112
tags:
1213
- controller.service_arguments

0 commit comments

Comments
 (0)