1414use OpenTelemetry \SDK \Trace \SpanExporter \InMemoryExporter ;
1515use OpenTelemetry \SDK \Trace \SpanProcessor \SimpleSpanProcessor ;
1616use OpenTelemetry \SDK \Trace \TracerProvider ;
17- use OpenTelemetry \SemConv \TraceAttributes ;
17+ use OpenTelemetry \SemConv \Attributes \ DbAttributes ;
1818use OpenTelemetry \TestUtils \TraceStructureAssertionTrait ;
1919use PDO ;
2020use PHPUnit \Framework \TestCase ;
@@ -85,7 +85,7 @@ public function test_pdo_construct(): void
8585 $ this ->assertCount (1 , $ this ->storage );
8686 $ span = $ this ->storage ->offsetGet (0 );
8787 $ this ->assertSame ('PDO::__construct ' , $ span ->getName ());
88- $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (TraceAttributes ::DB_SYSTEM_NAME ));
88+ $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (DbAttributes ::DB_SYSTEM_NAME ));
8989 }
9090
9191 /**
@@ -112,7 +112,7 @@ public function test_pdo_sqlite_subclass(): void
112112 $ this ->assertCount (1 , $ this ->storage );
113113 $ span = $ this ->storage ->offsetGet (0 );
114114 $ this ->assertSame ('PDO::connect ' , $ span ->getName ());
115- $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (TraceAttributes ::DB_SYSTEM_NAME ));
115+ $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (DbAttributes ::DB_SYSTEM_NAME ));
116116
117117 // Test that the subclass-specific methods work
118118 $ db ->createFunction ('test_function ' , static fn ($ value ) => strtoupper ($ value ));
@@ -121,15 +121,15 @@ public function test_pdo_sqlite_subclass(): void
121121 $ db ->exec ($ this ->fillDB ());
122122 $ span = $ this ->storage ->offsetGet (1 );
123123 $ this ->assertSame ('PDO::exec ' , $ span ->getName ());
124- $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (TraceAttributes ::DB_SYSTEM_NAME ));
124+ $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (DbAttributes ::DB_SYSTEM_NAME ));
125125 $ this ->assertCount (2 , $ this ->storage );
126126
127127 // Test that the custom function works
128128 $ result = $ db ->query ("SELECT test_function('hello') " )->fetchColumn ();
129129 $ this ->assertEquals ('HELLO ' , $ result );
130130 $ span = $ this ->storage ->offsetGet (2 );
131131 $ this ->assertSame ('PDO::query ' , $ span ->getName ());
132- $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (TraceAttributes ::DB_SYSTEM_NAME ));
132+ $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (DbAttributes ::DB_SYSTEM_NAME ));
133133 $ this ->assertCount (3 , $ this ->storage );
134134 }
135135
@@ -148,32 +148,32 @@ public function test_statement_execution(): void
148148 $ db ->exec ($ statement );
149149 $ span = $ this ->storage ->offsetGet (1 );
150150 $ this ->assertSame ('PDO::exec ' , $ span ->getName ());
151- $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (TraceAttributes ::DB_SYSTEM_NAME ));
151+ $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (DbAttributes ::DB_SYSTEM_NAME ));
152152 $ this ->assertFalse ($ db ->inTransaction ());
153153 $ this ->assertCount (2 , $ this ->storage );
154154
155155 $ sth = $ db ->prepare ('SELECT * FROM `technology` ' );
156156 $ span = $ this ->storage ->offsetGet (2 );
157157 $ this ->assertSame ('PDO::prepare ' , $ span ->getName ());
158- $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (TraceAttributes ::DB_SYSTEM_NAME ));
158+ $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (DbAttributes ::DB_SYSTEM_NAME ));
159159 $ this ->assertCount (3 , $ this ->storage );
160160
161161 $ sth ->execute ();
162162 $ span = $ this ->storage ->offsetGet (3 );
163163 $ this ->assertSame ('PDOStatement::execute ' , $ span ->getName ());
164- $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (TraceAttributes ::DB_SYSTEM_NAME ));
164+ $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (DbAttributes ::DB_SYSTEM_NAME ));
165165 $ this ->assertCount (4 , $ this ->storage );
166166
167167 $ sth ->fetchAll ();
168168 $ span = $ this ->storage ->offsetGet (4 );
169169 $ this ->assertSame ('PDOStatement::fetchAll ' , $ span ->getName ());
170- $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (TraceAttributes ::DB_SYSTEM_NAME ));
170+ $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (DbAttributes ::DB_SYSTEM_NAME ));
171171 $ this ->assertCount (5 , $ this ->storage );
172172
173173 $ db ->query ('SELECT * FROM `technology` ' );
174174 $ span = $ this ->storage ->offsetGet (5 );
175175 $ this ->assertSame ('PDO::query ' , $ span ->getName ());
176- $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (TraceAttributes ::DB_SYSTEM_NAME ));
176+ $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (DbAttributes ::DB_SYSTEM_NAME ));
177177 $ this ->assertCount (6 , $ this ->storage );
178178 }
179179
@@ -183,7 +183,7 @@ public function test_transaction(): void
183183 $ result = $ db ->beginTransaction ();
184184 $ span = $ this ->storage ->offsetGet (1 );
185185 $ this ->assertSame ('PDO::beginTransaction ' , $ span ->getName ());
186- $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (TraceAttributes ::DB_SYSTEM_NAME ));
186+ $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (DbAttributes ::DB_SYSTEM_NAME ));
187187 $ this ->assertCount (2 , $ this ->storage );
188188 $ this ->assertSame ($ result , true );
189189
@@ -192,7 +192,7 @@ public function test_transaction(): void
192192 $ result = $ db ->commit ();
193193 $ span = $ this ->storage ->offsetGet (3 );
194194 $ this ->assertSame ('PDO::commit ' , $ span ->getName ());
195- $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (TraceAttributes ::DB_SYSTEM_NAME ));
195+ $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (DbAttributes ::DB_SYSTEM_NAME ));
196196 $ this ->assertCount (4 , $ this ->storage );
197197 $ this ->assertTrue ($ result );
198198
@@ -204,7 +204,7 @@ public function test_transaction(): void
204204 $ result = $ db ->rollback ();
205205 $ span = $ this ->storage ->offsetGet (6 );
206206 $ this ->assertSame ('PDO::rollBack ' , $ span ->getName ());
207- $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (TraceAttributes ::DB_SYSTEM_NAME ));
207+ $ this ->assertEquals ('sqlite ' , $ span ->getAttributes ()->get (DbAttributes ::DB_SYSTEM_NAME ));
208208 $ this ->assertCount (7 , $ this ->storage );
209209 $ this ->assertTrue ($ result );
210210 $ this ->assertFalse ($ db ->inTransaction ());
@@ -262,17 +262,17 @@ public function test_encode_db_statement_as_utf8(): void
262262
263263 $ db ->prepare ("SELECT id FROM technology WHERE id = ' {$ non_utf8_id }' " );
264264 $ span_db_prepare = $ this ->storage ->offsetGet (2 );
265- $ this ->assertTrue (mb_check_encoding ($ span_db_prepare ->getAttributes ()->get (TraceAttributes ::DB_QUERY_TEXT ), 'UTF-8 ' ));
265+ $ this ->assertTrue (mb_check_encoding ($ span_db_prepare ->getAttributes ()->get (DbAttributes ::DB_QUERY_TEXT ), 'UTF-8 ' ));
266266 $ this ->assertCount (3 , $ this ->storage );
267267
268268 $ db ->query ("SELECT id FROM technology WHERE id = ' {$ non_utf8_id }' " );
269269 $ span_db_query = $ this ->storage ->offsetGet (3 );
270- $ this ->assertTrue (mb_check_encoding ($ span_db_query ->getAttributes ()->get (TraceAttributes ::DB_QUERY_TEXT ), 'UTF-8 ' ));
270+ $ this ->assertTrue (mb_check_encoding ($ span_db_query ->getAttributes ()->get (DbAttributes ::DB_QUERY_TEXT ), 'UTF-8 ' ));
271271 $ this ->assertCount (4 , $ this ->storage );
272272
273273 $ db ->exec ("SELECT id FROM technology WHERE id = ' {$ non_utf8_id }' " );
274274 $ span_db_exec = $ this ->storage ->offsetGet (4 );
275- $ this ->assertTrue (mb_check_encoding ($ span_db_exec ->getAttributes ()->get (TraceAttributes ::DB_QUERY_TEXT ), 'UTF-8 ' ));
275+ $ this ->assertTrue (mb_check_encoding ($ span_db_exec ->getAttributes ()->get (DbAttributes ::DB_QUERY_TEXT ), 'UTF-8 ' ));
276276 $ this ->assertCount (5 , $ this ->storage );
277277 }
278278
@@ -364,35 +364,35 @@ public function test_span_hierarchy_with_pdo_operations(): void
364364 'name ' => 'PDO::__construct ' ,
365365 'kind ' => SpanKind::KIND_CLIENT ,
366366 'attributes ' => [
367- TraceAttributes ::DB_SYSTEM_NAME => 'sqlite ' ,
367+ DbAttributes ::DB_SYSTEM_NAME => 'sqlite ' ,
368368 ],
369369 ],
370370 [
371371 'name ' => 'PDO::exec ' ,
372372 'kind ' => SpanKind::KIND_CLIENT ,
373373 'attributes ' => [
374- TraceAttributes ::DB_SYSTEM_NAME => 'sqlite ' ,
374+ DbAttributes ::DB_SYSTEM_NAME => 'sqlite ' ,
375375 ],
376376 ],
377377 [
378378 'name ' => 'PDO::prepare ' ,
379379 'kind ' => SpanKind::KIND_CLIENT ,
380380 'attributes ' => [
381- TraceAttributes ::DB_SYSTEM_NAME => 'sqlite ' ,
381+ DbAttributes ::DB_SYSTEM_NAME => 'sqlite ' ,
382382 ],
383383 ],
384384 [
385385 'name ' => 'PDOStatement::execute ' ,
386386 'kind ' => SpanKind::KIND_CLIENT ,
387387 'attributes ' => [
388- TraceAttributes ::DB_SYSTEM_NAME => 'sqlite ' ,
388+ DbAttributes ::DB_SYSTEM_NAME => 'sqlite ' ,
389389 ],
390390 ],
391391 [
392392 'name ' => 'PDOStatement::fetchAll ' ,
393393 'kind ' => SpanKind::KIND_CLIENT ,
394394 'attributes ' => [
395- TraceAttributes ::DB_SYSTEM_NAME => 'sqlite ' ,
395+ DbAttributes ::DB_SYSTEM_NAME => 'sqlite ' ,
396396 ],
397397 ],
398398 ],
0 commit comments