Skip to content

Commit b2864cc

Browse files
committed
limited the opt-in to postgresql & mysql only
1 parent b9d81f2 commit b2864cc

File tree

2 files changed

+2
-26
lines changed

2 files changed

+2
-26
lines changed

src/Instrumentation/PDO/README.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,14 @@ OTEL_PHP_INSTRUMENTATION_PDO_DISTRIBUTE_STATEMENT_TO_LINKED_SPANS=true
3636
```
3737

3838
### SQL Commenter feature
39-
The [sqlcommenter](https://google.github.io/sqlcommenter/) feature can be enabled using configuration directive:
39+
The [sqlcommenter](https://google.github.io/sqlcommenter/) feature can be enabled using configuration directive, currently it can be used with `postgresql` and `mysql` drivers.:
4040
```
4141
otel.instrumentation.pdo.sql_commenter = true
4242
```
4343
or environment variable:
4444
```shell
4545
OTEL_PHP_INSTRUMENTATION_PDO_SQL_COMMENTER=true
4646
```
47-
To select which database(s) to opt-in, specify the database(s) using configuration directive:
48-
49-
Valid values are `postgresql`, `mysql`, `sqlite`, `mssql`, `oracle`, `db2`, `other_sql` and `all`.
50-
51-
```
52-
otel.instrumentation.pdo.sql_commenter.database[]=postgresql
53-
otel.instrumentation.pdo.sql_commenter.database[]=mysql
54-
```
55-
or environment variable:
56-
```shell
57-
OTEL_PHP_INSTRUMENTATION_PDO_SQL_COMMENTER_DATABASE=postgresql,mysql
58-
```
5947

6048
This feature by default will append a SQL comment to the query statement with the information about the code that executed the query.
6149
The SQL comment can be configured to prepend to the query statement using the following configuration directive:

src/Instrumentation/PDO/src/PDOInstrumentation.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class PDOInstrumentation
2323
{
2424
public const NAME = 'pdo';
2525
private const UNDEFINED = 'undefined';
26-
private const ALL = 'all';
2726

2827
public static function register(): void
2928
{
@@ -402,15 +401,6 @@ private static function isSqlCommenterAttributeEnabled(): bool
402401
return filter_var(get_cfg_var('otel.instrumentation.pdo.sql_commenter.attribute'), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) ?? false;
403402
}
404403

405-
private static function getSqlCommenterDatabase(): array
406-
{
407-
if (class_exists('OpenTelemetry\SDK\Common\Configuration\Configuration') && count($values = Configuration::getList('OTEL_PHP_INSTRUMENTATION_PDO_SQL_COMMENTER_DATABASE', [])) > 0) {
408-
return $values;
409-
}
410-
411-
return (array) (get_cfg_var('otel.instrumentation.pdo.sql_commenter.database') ?: []);
412-
}
413-
414404
private static function addSqlComments(string $query): string
415405
{
416406
$comments = [];
@@ -428,8 +418,6 @@ private static function addSqlComments(string $query): string
428418

429419
private static function isSQLCommenterOptInDatabase(string $db) : bool
430420
{
431-
$optInList = self::getSqlCommenterDatabase();
432-
433-
return in_array(strtolower($db), $optInList) || in_array(self::ALL, $optInList);
421+
return $db == "postgresql" || $db == "mysql";
434422
}
435423
}

0 commit comments

Comments
 (0)