55
66use Doctrine \DBAL \Cache \QueryCacheProfile ;
77use Doctrine \DBAL \Connection ;
8+ use Doctrine \DBAL \Jaeger \Tag \DbalAutoCommitTag ;
89use Doctrine \DBAL \Jaeger \Tag \DbalErrorCodeTag ;
10+ use Doctrine \DBAL \Jaeger \Tag \DbalNestingLevelTag ;
911use Doctrine \DBAL \Jaeger \Tag \DbalRowNumberTag ;
1012use Jaeger \Tag \DbInstanceTag ;
1113use Jaeger \Tag \DbStatementTag ;
@@ -28,14 +30,35 @@ public function setTracer(TracerInterface $tracer)
2830 return $ this ;
2931 }
3032
33+ public function connect ()
34+ {
35+ $ span = $ this ->tracer
36+ ->start ('dbal.connect ' )
37+ ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
38+ ->addTag (new DbUser ($ this ->getUsername ()))
39+ ->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()))
40+ ->addTag (new DbalNestingLevelTag ($ this ->getTransactionNestingLevel ()));
41+ try {
42+ parent ::connect ();
43+ } catch (\Exception $ e ) {
44+ $ span ->addTag (new DbalErrorCodeTag ($ e ->getCode ()))
45+ ->addTag (new ErrorTag ());
46+ throw $ e ;
47+ } finally {
48+ $ this ->tracer ->finish ($ span ->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ())));
49+ }
50+ }
51+
3152 public function prepare ($ prepareString )
3253 {
3354 $ span = $ this ->tracer
3455 ->start ('dbal.prepare ' )
3556 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
3657 ->addTag (new DbUser ($ this ->getUsername ()))
37- ->addTag (new DbType ('sql ' ))
38- ->addTag (new DbStatementTag ($ prepareString ));
58+ ->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
59+ ->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()))
60+ ->addTag (new DbStatementTag ($ prepareString ))
61+ ->addTag (new DbalNestingLevelTag ($ this ->getTransactionNestingLevel ()));
3962 try {
4063 return parent ::prepare ($ prepareString );
4164 } catch (\Exception $ e ) {
@@ -53,8 +76,10 @@ public function executeQuery($query, array $params = [], $types = [], QueryCache
5376 ->start ('dbal.execute ' )
5477 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
5578 ->addTag (new DbUser ($ this ->getUsername ()))
56- ->addTag (new DbType ('sql ' ))
57- ->addTag (new DbStatementTag ($ query ));
79+ ->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
80+ ->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()))
81+ ->addTag (new DbStatementTag ($ query ))
82+ ->addTag (new DbalNestingLevelTag ($ this ->getTransactionNestingLevel ()));
5883 try {
5984 return parent ::executeQuery ($ query , $ params , $ types , $ qcp );
6085 } catch (\Exception $ e ) {
@@ -72,8 +97,10 @@ public function executeUpdate($query, array $params = [], array $types = [])
7297 ->start ('dbal.execute ' )
7398 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
7499 ->addTag (new DbUser ($ this ->getUsername ()))
75- ->addTag (new DbType ('sql ' ))
76- ->addTag (new DbStatementTag ($ query ));
100+ ->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
101+ ->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()))
102+ ->addTag (new DbStatementTag ($ query ))
103+ ->addTag (new DbalNestingLevelTag ($ this ->getTransactionNestingLevel ()));
77104 try {
78105 return parent ::executeUpdate ($ query , $ params , $ types );
79106 } catch (\Exception $ e ) {
@@ -91,7 +118,9 @@ public function query()
91118 ->start ('dbal.query ' )
92119 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
93120 ->addTag (new DbUser ($ this ->getUsername ()))
94- ->addTag (new DbType ('sql ' ));
121+ ->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
122+ ->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()))
123+ ->addTag (new DbalNestingLevelTag ($ this ->getTransactionNestingLevel ()));
95124 try {
96125 return parent ::query ();
97126 } catch (\Exception $ e ) {
@@ -109,7 +138,9 @@ public function exec($statement)
109138 ->start ('dbal.exec ' )
110139 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
111140 ->addTag (new DbUser ($ this ->getUsername ()))
112- ->addTag (new DbType ('sql ' ));
141+ ->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
142+ ->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()))
143+ ->addTag (new DbalNestingLevelTag ($ this ->getTransactionNestingLevel ()));
113144 try {
114145 $ rows = parent ::exec ($ statement );
115146 $ span ->addTag (new DbalRowNumberTag ($ rows ));
@@ -130,15 +161,16 @@ public function beginTransaction()
130161 ->start ('dbal.transaction ' )
131162 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
132163 ->addTag (new DbUser ($ this ->getUsername ()))
133- ->addTag (new DbType ('sql ' ));
164+ ->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
165+ ->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()));
134166 try {
135167 parent ::beginTransaction ();
136168 } catch (\Exception $ e ) {
137169 $ span ->addTag (new DbalErrorCodeTag ($ e ->getCode ()))
138170 ->addTag (new ErrorTag ());
139171 throw $ e ;
140172 } finally {
141- $ this ->tracer ->finish ($ span );
173+ $ this ->tracer ->finish ($ span-> addTag ( new DbalNestingLevelTag ( $ this -> getTransactionNestingLevel ())) );
142174 }
143175 }
144176
@@ -148,15 +180,16 @@ public function commit()
148180 ->start ('dbal.commit ' )
149181 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
150182 ->addTag (new DbUser ($ this ->getUsername ()))
151- ->addTag (new DbType ('sql ' ));
183+ ->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
184+ ->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()));
152185 try {
153186 parent ::commit ();
154187 } catch (\Exception $ e ) {
155188 $ span ->addTag (new DbalErrorCodeTag ($ e ->getCode ()))
156189 ->addTag (new ErrorTag ());
157190 throw $ e ;
158191 } finally {
159- $ this ->tracer ->finish ($ span );
192+ $ this ->tracer ->finish ($ span-> addTag ( new DbalNestingLevelTag ( $ this -> getTransactionNestingLevel ())) );
160193 }
161194 }
162195
@@ -166,15 +199,16 @@ public function rollBack()
166199 ->start ('dbal.rollback ' )
167200 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
168201 ->addTag (new DbUser ($ this ->getUsername ()))
169- ->addTag (new DbType ('sql ' ));
202+ ->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
203+ ->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()));
170204 try {
171205 return parent ::rollBack ();
172206 } catch (\Exception $ e ) {
173207 $ span ->addTag (new DbalErrorCodeTag ($ e ->getCode ()))
174208 ->addTag (new ErrorTag ());
175209 throw $ e ;
176210 } finally {
177- $ this ->tracer ->finish ($ span );
211+ $ this ->tracer ->finish ($ span-> addTag ( new DbalNestingLevelTag ( $ this -> getTransactionNestingLevel ())) );
178212 }
179213 }
180214}
0 commit comments