@@ -152,6 +152,49 @@ describe('Plugin', () => {
152
152
tracingPromise
153
153
] )
154
154
} )
155
+
156
+ it ( 'should include database connection attributes in db_query spans' , async ( ) => {
157
+ // Set up database config that should be parsed from connection URL
158
+ const dbConfig = {
159
+ user : 'foo' ,
160
+ host : 'localhost' ,
161
+ port : '5432' ,
162
+ database : 'postgres'
163
+ }
164
+ tracingHelper . setDbString ( dbConfig )
165
+
166
+ const tracingPromise = agent . assertSomeTraces ( traces => {
167
+ // Find the db_query span
168
+ const dbQuerySpan = traces [ 0 ] . find ( span => span . meta [ 'prisma.name' ] === 'db_query' )
169
+ expect ( dbQuerySpan ) . to . exist
170
+
171
+ // Verify database connection attributes are present
172
+ expect ( dbQuerySpan . meta ) . to . have . property ( 'db.name' , 'postgres' )
173
+ expect ( dbQuerySpan . meta ) . to . have . property ( 'db.user' , 'foo' )
174
+ expect ( dbQuerySpan . meta ) . to . have . property ( 'out.host' , 'localhost' )
175
+ expect ( dbQuerySpan . meta ) . to . have . property ( 'network.destination.port' , '5432' )
176
+ expect ( dbQuerySpan . meta ) . to . have . property ( 'db.type' , 'postgres' )
177
+ } )
178
+
179
+ const engineSpans = [
180
+ {
181
+ id : '1' ,
182
+ parentId : null ,
183
+ name : 'prisma:engine:db_query' ,
184
+ startTime : [ 1745340876 , 436861000 ] ,
185
+ endTime : [ 1745340876 , 438601541 ] ,
186
+ kind : 'client' ,
187
+ attributes : {
188
+ 'db.system' : 'postgresql' ,
189
+ 'db.query.text' : 'SELECT 1'
190
+ }
191
+ }
192
+ ]
193
+ tracingHelper . dispatchEngineSpans ( engineSpans )
194
+ await Promise . all ( [
195
+ tracingPromise
196
+ ] )
197
+ } )
155
198
} )
156
199
157
200
describe ( 'with configuration' , ( ) => {
0 commit comments