Skip to content

Commit a8d478d

Browse files
committed
move controller registration into main config
1 parent 79d4196 commit a8d478d

File tree

3 files changed

+20
-45
lines changed

3 files changed

+20
-45
lines changed

tests/End2End/App/Controller/TracingController.php

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,50 +29,26 @@ public function __construct(HubInterface $hub, ?Connection $connection = null)
2929

3030
public function pingDatabase(): Response
3131
{
32-
try {
33-
$this->hub->setSpan(
34-
$this->hub->getSpan()
35-
->startChild($this->createSpan())
36-
);
32+
$this->hub->setSpan(
33+
$this->hub->getSpan()
34+
->startChild($this->createSpan())
35+
);
3736

38-
if ($this->connection) {
39-
$this->connection->executeQuery('SELECT 1');
40-
}
41-
42-
return new Response('Success');
43-
} catch (\Throwable $e) {
44-
$errorMessage = sprintf(
45-
"Exception: %s\nMessage: %s\nFile: %s\nLine: %d",
46-
get_class($e),
47-
$e->getMessage(),
48-
$e->getFile(),
49-
$e->getLine()
50-
);
51-
52-
return new Response($errorMessage, 200);
37+
if ($this->connection) {
38+
$this->connection->executeQuery('SELECT 1');
5339
}
40+
41+
return new Response('Success');
5442
}
5543

5644
public function ignoredTransaction(): Response
5745
{
58-
try {
59-
$this->hub->setSpan(
60-
$this->hub->getSpan()
61-
->startChild($this->createSpan())
62-
);
46+
$this->hub->setSpan(
47+
$this->hub->getSpan()
48+
->startChild($this->createSpan())
49+
);
6350

64-
return new Response('Success');
65-
} catch (\Throwable $e) {
66-
$errorMessage = sprintf(
67-
"Exception: %s\nMessage: %s\nFile: %s\nLine: %d",
68-
get_class($e),
69-
$e->getMessage(),
70-
$e->getFile(),
71-
$e->getLine()
72-
);
73-
74-
return new Response($errorMessage, 200);
75-
}
51+
return new Response('Success');
7652
}
7753

7854
private function createSpan(): SpanContext

tests/End2End/App/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ services:
3333
tags:
3434
- controller.service_arguments
3535

36+
Sentry\SentryBundle\Tests\End2End\App\Controller\TracingController:
37+
arguments:
38+
$hub: '@Sentry\State\HubInterface'
39+
$connection: '@?doctrine.dbal.default_connection'
40+
tags:
41+
- controller.service_arguments
42+
3643
Sentry\SentryBundle\Tests\End2End\App\Command\MainCommand:
3744
tags: [{ name: 'console.command', command: 'main-command' }]
3845

tests/End2End/App/tracing.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,3 @@ sentry:
33
enabled: true
44
options:
55
traces_sample_rate: 1
6-
7-
services:
8-
Sentry\SentryBundle\Tests\End2End\App\Controller\TracingController:
9-
arguments:
10-
$hub: '@Sentry\State\HubInterface'
11-
$connection: '@?doctrine.dbal.default_connection'
12-
tags:
13-
- { name: controller.service_arguments }

0 commit comments

Comments
 (0)