22
33declare (strict_types=1 );
44
5- namespace Sentry \SentryBundle \EventListener \ Tracing ;
5+ namespace Sentry \SentryBundle \Tracing ;
66
77use Doctrine \DBAL \Logging \SQLLogger ;
88use Sentry \State \HubInterface ;
99use Sentry \Tracing \Span ;
1010use Sentry \Tracing \SpanContext ;
1111use Sentry \Tracing \Transaction ;
1212
13- /**
14- * Getting the logger, tied into dbal seems extremely hard. Cheating the system a bit by putting it in between the
15- * debug stack logger.
16- */
17- final class DbalListener implements SQLLogger
13+ final class DbalSqlTracingLogger implements SQLLogger
1814{
1915 /**
2016 * @var HubInterface The current hub
2117 */
2218 private $ hub ;
2319
2420 /**
25- * @var Span
21+ * @var Span The span tracing the execution of a query
2622 */
27- private $ querySpan ;
23+ private $ span ;
2824
2925 /**
3026 * @param HubInterface $hub The current hub
@@ -35,7 +31,7 @@ public function __construct(HubInterface $hub)
3531 }
3632
3733 /**
38- * @param string $sql
34+ * {@inheritdoc}
3935 */
4036 public function startQuery ($ sql , ?array $ params = null , ?array $ types = null )
4137 {
@@ -46,18 +42,24 @@ public function startQuery($sql, ?array $params = null, ?array $types = null)
4642 }
4743
4844 $ spanContext = new SpanContext ();
49- $ spanContext ->setOp ('doctrine .query ' );
45+ $ spanContext ->setOp ('db .query ' );
5046 $ spanContext ->setDescription ($ sql );
47+ $ spanContext ->setData ([
48+ 'db.system ' => 'doctrine ' ,
49+ ]);
5150
52- $ this ->querySpan = $ transaction ->startChild ($ spanContext );
51+ $ this ->span = $ transaction ->startChild ($ spanContext );
5352 }
5453
54+ /**
55+ * {@inheritdoc}
56+ */
5557 public function stopQuery ()
5658 {
57- if (! $ this ->querySpan instanceof Span ) {
59+ if (null === $ this ->span ) {
5860 return ;
5961 }
6062
61- $ this ->querySpan ->finish ();
63+ $ this ->span ->finish ();
6264 }
6365}
0 commit comments