@@ -18,19 +18,37 @@ class JaegerConnectionDecorator extends AbstractConnectionDecorator
1818{
1919 private $ tracer ;
2020
21- public function __construct (Connection $ connection , TracerInterface $ tracer )
22- {
23- $ this ->tracer = $ tracer ;
24- parent ::__construct ($ connection );
25- }
21+ public function __construct (Connection $ connection , TracerInterface $ tracer )
22+ {
23+ $ this ->tracer = $ tracer ;
24+ parent ::__construct ($ connection );
25+ }
26+
27+ public function connect ()
28+ {
29+ $ span = $ this ->tracer
30+ ->start ('dbal.connect ' )
31+ ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
32+ ->addTag (new DbUser ($ this ->getUsername ()))
33+ ->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()));
34+ try {
35+ parent ::connect ();
36+ } catch (\Exception $ e ) {
37+ $ span ->addTag (new DbalErrorCodeTag ($ e ->getCode ()))
38+ ->addTag (new ErrorTag ());
39+ throw $ e ;
40+ } finally {
41+ $ this ->tracer ->finish ($ span );
42+ }
43+ }
2644
2745 public function prepare ($ prepareString )
2846 {
2947 $ span = $ this ->tracer
3048 ->start ('dbal.prepare ' )
3149 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
3250 ->addTag (new DbUser ($ this ->getUsername ()))
33- ->addTag (new DbType (' sql ' ))
51+ ->addTag (new DbType ($ this -> getDatabasePlatform ()-> getName () ))
3452 ->addTag (new DbStatementTag ($ prepareString ));
3553 try {
3654 return parent ::prepare ($ prepareString );
@@ -49,7 +67,7 @@ public function executeQuery($query, array $params = [], $types = [], QueryCache
4967 ->start ('dbal.execute ' )
5068 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
5169 ->addTag (new DbUser ($ this ->getUsername ()))
52- ->addTag (new DbType (' sql ' ))
70+ ->addTag (new DbType ($ this -> getDatabasePlatform ()-> getName () ))
5371 ->addTag (new DbStatementTag ($ query ));
5472 try {
5573 return parent ::executeQuery ($ query , $ params , $ types , $ qcp );
@@ -68,7 +86,7 @@ public function executeUpdate($query, array $params = [], array $types = [])
6886 ->start ('dbal.execute ' )
6987 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
7088 ->addTag (new DbUser ($ this ->getUsername ()))
71- ->addTag (new DbType (' sql ' ))
89+ ->addTag (new DbType ($ this -> getDatabasePlatform ()-> getName () ))
7290 ->addTag (new DbStatementTag ($ query ));
7391 try {
7492 return parent ::executeUpdate ($ query , $ params , $ types );
@@ -81,15 +99,13 @@ public function executeUpdate($query, array $params = [], array $types = [])
8199 }
82100 }
83101
84-
85-
86102 public function query ()
87103 {
88104 $ span = $ this ->tracer
89105 ->start ('dbal.query ' )
90106 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
91107 ->addTag (new DbUser ($ this ->getUsername ()))
92- ->addTag (new DbType (' sql ' ));
108+ ->addTag (new DbType ($ this -> getDatabasePlatform ()-> getName () ));
93109 try {
94110 return parent ::query ();
95111 } catch (\Exception $ e ) {
@@ -107,7 +123,7 @@ public function exec($statement)
107123 ->start ('dbal.exec ' )
108124 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
109125 ->addTag (new DbUser ($ this ->getUsername ()))
110- ->addTag (new DbType (' sql ' ));
126+ ->addTag (new DbType ($ this -> getDatabasePlatform ()-> getName () ));
111127 try {
112128 $ rows = parent ::exec ($ statement );
113129 $ span ->addTag (new DbalRowNumberTag ($ rows ));
@@ -128,7 +144,7 @@ public function beginTransaction()
128144 ->start ('dbal.transaction ' )
129145 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
130146 ->addTag (new DbUser ($ this ->getUsername ()))
131- ->addTag (new DbType (' sql ' ));
147+ ->addTag (new DbType ($ this -> getDatabasePlatform ()-> getName () ));
132148 try {
133149 parent ::beginTransaction ();
134150 } catch (\Exception $ e ) {
@@ -146,7 +162,7 @@ public function commit()
146162 ->start ('dbal.commit ' )
147163 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
148164 ->addTag (new DbUser ($ this ->getUsername ()))
149- ->addTag (new DbType (' sql ' ));
165+ ->addTag (new DbType ($ this -> getDatabasePlatform ()-> getName () ));
150166 try {
151167 parent ::commit ();
152168 } catch (\Exception $ e ) {
@@ -164,7 +180,7 @@ public function rollBack()
164180 ->start ('dbal.rollback ' )
165181 ->addTag (new DbInstanceTag ($ this ->getDatabase ()))
166182 ->addTag (new DbUser ($ this ->getUsername ()))
167- ->addTag (new DbType (' sql ' ));
183+ ->addTag (new DbType ($ this -> getDatabasePlatform ()-> getName () ));
168184 try {
169185 return parent ::rollBack ();
170186 } catch (\Exception $ e ) {
0 commit comments