Skip to content

Commit

Permalink
Explicitly convert query to utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
John98Zakaria committed Sep 19, 2024
1 parent c549d0f commit bc08d15
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/Instrumentation/PDO/src/PDOInstrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit bc08d15

Please sign in to comment.