Skip to content

Commit bf41655

Browse files
committed
Added DbalAutoCommit tag
1 parent c3cad55 commit bf41655

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

src/Decorator/JaegerConnectionDecorator.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use Doctrine\DBAL\Cache\QueryCacheProfile;
77
use Doctrine\DBAL\Connection;
8+
use Doctrine\DBAL\Jaeger\Tag\DbalAutoCommitTag;
89
use Doctrine\DBAL\Jaeger\Tag\DbalErrorCodeTag;
910
use Doctrine\DBAL\Jaeger\Tag\DbalRowNumberTag;
1011
use Jaeger\Tag\DbInstanceTag;
@@ -30,7 +31,8 @@ public function connect()
3031
->start('dbal.connect')
3132
->addTag(new DbInstanceTag($this->getDatabase()))
3233
->addTag(new DbUser($this->getUsername()))
33-
->addTag(new DbType($this->getDatabasePlatform()->getName()));
34+
->addTag(new DbType($this->getDatabasePlatform()->getName()))
35+
->addTag(new DbalAutoCommitTag($this->isAutoCommit()));
3436
try {
3537
parent::connect();
3638
} catch (\Exception $e) {
@@ -49,6 +51,7 @@ public function prepare($prepareString)
4951
->addTag(new DbInstanceTag($this->getDatabase()))
5052
->addTag(new DbUser($this->getUsername()))
5153
->addTag(new DbType($this->getDatabasePlatform()->getName()))
54+
->addTag(new DbalAutoCommitTag($this->isAutoCommit()))
5255
->addTag(new DbStatementTag($prepareString));
5356
try {
5457
return parent::prepare($prepareString);
@@ -68,6 +71,7 @@ public function executeQuery($query, array $params = [], $types = [], QueryCache
6871
->addTag(new DbInstanceTag($this->getDatabase()))
6972
->addTag(new DbUser($this->getUsername()))
7073
->addTag(new DbType($this->getDatabasePlatform()->getName()))
74+
->addTag(new DbalAutoCommitTag($this->isAutoCommit()))
7175
->addTag(new DbStatementTag($query));
7276
try {
7377
return parent::executeQuery($query, $params, $types, $qcp);
@@ -87,6 +91,7 @@ public function executeUpdate($query, array $params = [], array $types = [])
8791
->addTag(new DbInstanceTag($this->getDatabase()))
8892
->addTag(new DbUser($this->getUsername()))
8993
->addTag(new DbType($this->getDatabasePlatform()->getName()))
94+
->addTag(new DbalAutoCommitTag($this->isAutoCommit()))
9095
->addTag(new DbStatementTag($query));
9196
try {
9297
return parent::executeUpdate($query, $params, $types);
@@ -105,7 +110,8 @@ public function query()
105110
->start('dbal.query')
106111
->addTag(new DbInstanceTag($this->getDatabase()))
107112
->addTag(new DbUser($this->getUsername()))
108-
->addTag(new DbType($this->getDatabasePlatform()->getName()));
113+
->addTag(new DbType($this->getDatabasePlatform()->getName()))
114+
->addTag(new DbalAutoCommitTag($this->isAutoCommit()));
109115
try {
110116
return parent::query();
111117
} catch (\Exception $e) {
@@ -123,7 +129,8 @@ public function exec($statement)
123129
->start('dbal.exec')
124130
->addTag(new DbInstanceTag($this->getDatabase()))
125131
->addTag(new DbUser($this->getUsername()))
126-
->addTag(new DbType($this->getDatabasePlatform()->getName()));
132+
->addTag(new DbType($this->getDatabasePlatform()->getName()))
133+
->addTag(new DbalAutoCommitTag($this->isAutoCommit()));
127134
try {
128135
$rows = parent::exec($statement);
129136
$span->addTag(new DbalRowNumberTag($rows));
@@ -144,7 +151,8 @@ public function beginTransaction()
144151
->start('dbal.transaction')
145152
->addTag(new DbInstanceTag($this->getDatabase()))
146153
->addTag(new DbUser($this->getUsername()))
147-
->addTag(new DbType($this->getDatabasePlatform()->getName()));
154+
->addTag(new DbType($this->getDatabasePlatform()->getName()))
155+
->addTag(new DbalAutoCommitTag($this->isAutoCommit()));
148156
try {
149157
parent::beginTransaction();
150158
} catch (\Exception $e) {
@@ -162,7 +170,8 @@ public function commit()
162170
->start('dbal.commit')
163171
->addTag(new DbInstanceTag($this->getDatabase()))
164172
->addTag(new DbUser($this->getUsername()))
165-
->addTag(new DbType($this->getDatabasePlatform()->getName()));
173+
->addTag(new DbType($this->getDatabasePlatform()->getName()))
174+
->addTag(new DbalAutoCommitTag($this->isAutoCommit()));
166175
try {
167176
parent::commit();
168177
} catch (\Exception $e) {
@@ -180,7 +189,8 @@ public function rollBack()
180189
->start('dbal.rollback')
181190
->addTag(new DbInstanceTag($this->getDatabase()))
182191
->addTag(new DbUser($this->getUsername()))
183-
->addTag(new DbType($this->getDatabasePlatform()->getName()));
192+
->addTag(new DbType($this->getDatabasePlatform()->getName()))
193+
->addTag(new DbalAutoCommitTag($this->isAutoCommit()));
184194
try {
185195
return parent::rollBack();
186196
} catch (\Exception $e) {

src/Tag/DbalAutoCommitTag.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Doctrine\DBAL\Jaeger\Tag;
5+
6+
use Jaeger\Tag\BoolTag;
7+
8+
class DbalAutoCommitTag extends BoolTag
9+
{
10+
public function __construct(bool $value)
11+
{
12+
parent::__construct('dbal.auto_commit', $value);
13+
}
14+
}

0 commit comments

Comments
 (0)