Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": "*"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rely on there being a polyfill available here (https://github.com/open-telemetry/opentelemetry-php/blob/main/src/API/composer.json#L23) and move mbstring to a suggestion (if it's better/more performant/etc) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such changes should also be added to src/Instrumentation/PDO/composer.json 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I removed the requirement from the root composer json

  • Added symfony/polyfill-mbstring as a requirement

  • Added ext-mbstring the extension as a suggested

},
"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] ?? 'undefined', 'UTF-8'));
}
$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] ?? 'undefined', 'UTF-8'));
}
$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] ?? 'undefined', 'UTF-8'));
}
$parent = Context::getCurrent();
$span = $builder->startSpan();
Expand Down
Loading