5
5
6
6
use Doctrine \DBAL \Cache \QueryCacheProfile ;
7
7
use Doctrine \DBAL \Connection ;
8
+ use Doctrine \DBAL \Jaeger \Tag \DbalAutoCommitTag ;
8
9
use Doctrine \DBAL \Jaeger \Tag \DbalErrorCodeTag ;
10
+ use Doctrine \DBAL \Jaeger \Tag \DbalNestingLevelTag ;
9
11
use Doctrine \DBAL \Jaeger \Tag \DbalRowNumberTag ;
10
12
use Jaeger \Tag \DbInstanceTag ;
11
13
use Jaeger \Tag \DbStatementTag ;
@@ -28,14 +30,35 @@ public function setTracer(TracerInterface $tracer)
28
30
return $ this ;
29
31
}
30
32
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
+
31
52
public function prepare ($ prepareString )
32
53
{
33
54
$ span = $ this ->tracer
34
55
->start ('dbal.prepare ' )
35
56
->addTag (new DbInstanceTag ($ this ->getDatabase ()))
36
57
->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 ()));
39
62
try {
40
63
return parent ::prepare ($ prepareString );
41
64
} catch (\Exception $ e ) {
@@ -53,8 +76,10 @@ public function executeQuery($query, array $params = [], $types = [], QueryCache
53
76
->start ('dbal.execute ' )
54
77
->addTag (new DbInstanceTag ($ this ->getDatabase ()))
55
78
->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 ()));
58
83
try {
59
84
return parent ::executeQuery ($ query , $ params , $ types , $ qcp );
60
85
} catch (\Exception $ e ) {
@@ -72,8 +97,10 @@ public function executeUpdate($query, array $params = [], array $types = [])
72
97
->start ('dbal.execute ' )
73
98
->addTag (new DbInstanceTag ($ this ->getDatabase ()))
74
99
->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 ()));
77
104
try {
78
105
return parent ::executeUpdate ($ query , $ params , $ types );
79
106
} catch (\Exception $ e ) {
@@ -91,7 +118,9 @@ public function query()
91
118
->start ('dbal.query ' )
92
119
->addTag (new DbInstanceTag ($ this ->getDatabase ()))
93
120
->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 ()));
95
124
try {
96
125
return parent ::query ();
97
126
} catch (\Exception $ e ) {
@@ -109,7 +138,9 @@ public function exec($statement)
109
138
->start ('dbal.exec ' )
110
139
->addTag (new DbInstanceTag ($ this ->getDatabase ()))
111
140
->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 ()));
113
144
try {
114
145
$ rows = parent ::exec ($ statement );
115
146
$ span ->addTag (new DbalRowNumberTag ($ rows ));
@@ -130,15 +161,16 @@ public function beginTransaction()
130
161
->start ('dbal.transaction ' )
131
162
->addTag (new DbInstanceTag ($ this ->getDatabase ()))
132
163
->addTag (new DbUser ($ this ->getUsername ()))
133
- ->addTag (new DbType ('sql ' ));
164
+ ->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
165
+ ->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()));
134
166
try {
135
167
parent ::beginTransaction ();
136
168
} catch (\Exception $ e ) {
137
169
$ span ->addTag (new DbalErrorCodeTag ($ e ->getCode ()))
138
170
->addTag (new ErrorTag ());
139
171
throw $ e ;
140
172
} finally {
141
- $ this ->tracer ->finish ($ span );
173
+ $ this ->tracer ->finish ($ span-> addTag ( new DbalNestingLevelTag ( $ this -> getTransactionNestingLevel ())) );
142
174
}
143
175
}
144
176
@@ -148,15 +180,16 @@ public function commit()
148
180
->start ('dbal.commit ' )
149
181
->addTag (new DbInstanceTag ($ this ->getDatabase ()))
150
182
->addTag (new DbUser ($ this ->getUsername ()))
151
- ->addTag (new DbType ('sql ' ));
183
+ ->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
184
+ ->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()));
152
185
try {
153
186
parent ::commit ();
154
187
} catch (\Exception $ e ) {
155
188
$ span ->addTag (new DbalErrorCodeTag ($ e ->getCode ()))
156
189
->addTag (new ErrorTag ());
157
190
throw $ e ;
158
191
} finally {
159
- $ this ->tracer ->finish ($ span );
192
+ $ this ->tracer ->finish ($ span-> addTag ( new DbalNestingLevelTag ( $ this -> getTransactionNestingLevel ())) );
160
193
}
161
194
}
162
195
@@ -166,15 +199,16 @@ public function rollBack()
166
199
->start ('dbal.rollback ' )
167
200
->addTag (new DbInstanceTag ($ this ->getDatabase ()))
168
201
->addTag (new DbUser ($ this ->getUsername ()))
169
- ->addTag (new DbType ('sql ' ));
202
+ ->addTag (new DbType ($ this ->getDatabasePlatform ()->getName ()))
203
+ ->addTag (new DbalAutoCommitTag ($ this ->isAutoCommit ()));
170
204
try {
171
205
return parent ::rollBack ();
172
206
} catch (\Exception $ e ) {
173
207
$ span ->addTag (new DbalErrorCodeTag ($ e ->getCode ()))
174
208
->addTag (new ErrorTag ());
175
209
throw $ e ;
176
210
} finally {
177
- $ this ->tracer ->finish ($ span );
211
+ $ this ->tracer ->finish ($ span-> addTag ( new DbalNestingLevelTag ( $ this -> getTransactionNestingLevel ())) );
178
212
}
179
213
}
180
214
}
0 commit comments