@@ -58,11 +58,6 @@ final class TracingDriverConnection implements DriverConnectionInterface
5858 */
5959 private $ decoratedConnection ;
6060
61- /**
62- * @var string The name of the database platform
63- */
64- private $ databasePlatform ;
65-
6661 /**
6762 * @var array<string, string> The tags to attach to the span
6863 */
@@ -84,18 +79,19 @@ public function __construct(
8479 ) {
8580 $ this ->hub = $ hub ;
8681 $ this ->decoratedConnection = $ decoratedConnection ;
87- $ this ->databasePlatform = $ databasePlatform ;
88- $ this ->spanTags = $ this ->getSpanTags ($ params );
82+ $ this ->spanTags = $ this ->getSpanTags ($ databasePlatform , $ params );
8983 }
9084
9185 /**
9286 * {@inheritdoc}
9387 */
9488 public function prepare ($ sql ): Statement
9589 {
96- return $ this ->traceFunction (self ::SPAN_OP_CONN_PREPARE , $ sql , function () use ($ sql ): Statement {
90+ $ statement = $ this ->traceFunction (self ::SPAN_OP_CONN_PREPARE , $ sql , function () use ($ sql ): Statement {
9791 return $ this ->decoratedConnection ->prepare ($ sql );
9892 });
93+
94+ return new TracingStatement ($ this ->hub , $ statement , $ sql , $ this ->spanTags );
9995 }
10096
10197 /**
@@ -225,15 +221,16 @@ private function traceFunction(string $spanOperation, string $spanDescription, \
225221 /**
226222 * Gets a map of key-value pairs that will be set as tags of the span.
227223 *
228- * @param array<string, mixed> $params The connection params
224+ * @param string $databasePlatform The database platform
225+ * @param array<string, mixed> $params The connection params
229226 *
230227 * @return array<string, string>
231228 *
232229 * @see https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/database.md
233230 */
234- private function getSpanTags (array $ params ): array
231+ private function getSpanTags (string $ databasePlatform , array $ params ): array
235232 {
236- $ tags = ['db.system ' => $ this -> databasePlatform ];
233+ $ tags = ['db.system ' => $ databasePlatform ];
237234
238235 if (isset ($ params ['user ' ])) {
239236 $ tags ['db.user ' ] = $ params ['user ' ];
0 commit comments