diff --git a/composer.json b/composer.json index 7ac30bc1..38cc232b 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,8 @@ "prefer-stable": true, "require": { "php": "^7.4 || ^8.0", - "ext-json": "*" + "ext-json": "*", + "ext-mbstring": "*" }, "require-dev": { "composer/xdebug-handler": "^2.0", diff --git a/src/Instrumentation/PDO/src/PDOInstrumentation.php b/src/Instrumentation/PDO/src/PDOInstrumentation.php index 16ae59ee..51e7e433 100644 --- a/src/Instrumentation/PDO/src/PDOInstrumentation.php +++ b/src/Instrumentation/PDO/src/PDOInstrumentation.php @@ -70,7 +70,7 @@ public static function register(): void $builder = self::makeBuilder($instrumentation, 'PDO::query', $function, $class, $filename, $lineno) ->setSpanKind(SpanKind::KIND_CLIENT); if ($class === PDO::class) { - $builder->setAttribute(TraceAttributes::DB_STATEMENT, $params[0] ?? 'undefined'); + $builder->setAttribute(TraceAttributes::DB_STATEMENT, mb_convert_encoding($params[0], 'UTF-8') ?? 'undefined'); } $parent = Context::getCurrent(); $span = $builder->startSpan(); @@ -93,7 +93,7 @@ public static function register(): void $builder = self::makeBuilder($instrumentation, 'PDO::exec', $function, $class, $filename, $lineno) ->setSpanKind(SpanKind::KIND_CLIENT); if ($class === PDO::class) { - $builder->setAttribute(TraceAttributes::DB_STATEMENT, $params[0] ?? 'undefined'); + $builder->setAttribute(TraceAttributes::DB_STATEMENT, mb_convert_encoding($params[0], 'UTF-8') ?? 'undefined'); } $parent = Context::getCurrent(); $span = $builder->startSpan(); @@ -116,7 +116,7 @@ public static function register(): void $builder = self::makeBuilder($instrumentation, 'PDO::prepare', $function, $class, $filename, $lineno) ->setSpanKind(SpanKind::KIND_CLIENT); if ($class === PDO::class) { - $builder->setAttribute(TraceAttributes::DB_STATEMENT, $params[0] ?? 'undefined'); + $builder->setAttribute(TraceAttributes::DB_STATEMENT, mb_convert_encoding($params[0], 'UTF-8') ?? 'undefined'); } $parent = Context::getCurrent(); $span = $builder->startSpan();