Summary
Add two complementary PHP PDO configuration variables that mirror the Go tracer's WithIgnoreQueryTypes() options:
DD_TRACE_PDO_PREPARED_STATEMENTS_ENABLED — suppress PDO.prepare + PDOStatement.execute spans
DD_TRACE_PDO_LIFECYCLE_COMMANDS_ENABLED — suppress connection and transaction lifecycle spans
Motivation
The Go tracer exposes fine-grained control over which DB operation types are traced via WithIgnoreQueryTypes(QueryType...). PHP had no equivalent. In high-throughput applications:
- Prepared statement spans (
PDO.prepare + execute) can generate noise when the query text is already visible on PDO.exec/PDO.query
- Lifecycle spans (
__construct, beginTransaction, commit, rollBack) have low diagnostic value in normal operation but contribute to trace volume
Both flags follow the same pattern already established for Redis (DD_TRACE_REDIS_LIFECYCLE_COMMANDS_ENABLED).
Go tracer equivalence
| PHP variable |
Go equivalent |
DD_TRACE_PDO_PREPARED_STATEMENTS_ENABLED=false |
WithIgnoreQueryTypes(QueryTypePrepare) |
DD_TRACE_PDO_LIFECYCLE_COMMANDS_ENABLED=false |
WithIgnoreQueryTypes(QueryTypeConnect, QueryTypeBegin, QueryTypeCommit, QueryTypeRollback) |
Note: unlike Go (code-level option), PHP exposes these as environment variables — configurable without redeployment.
Behaviour
DD_TRACE_PDO_PREPARED_STATEMENTS_ENABLED
| Span |
true (default) |
false |
PDO.prepare |
✅ |
❌ |
PDOStatement.execute |
✅ |
❌ |
PDO.exec / PDO.query |
✅ |
✅ |
DD_TRACE_PDO_LIFECYCLE_COMMANDS_ENABLED
| Span |
true (default) |
false |
PDO.__construct |
✅ |
❌ |
PDO.connect |
✅ |
❌ |
PDO.beginTransaction |
✅ |
❌ |
PDO.commit |
✅ |
❌ |
PDO.rollBack |
✅ |
❌ |
PDO.exec / PDO.query / prepared statements |
✅ |
✅ |
Note: connection metadata (out.host, db.system, etc.) is always preserved via ObjectKVStore so data command spans keep their tags regardless of the lifecycle flag.
Implementation scope
ext/configuration.h — two new CONFIG(BOOL, ...) declarations
src/DDTrace/Integrations/PDO/PDOIntegration.php — per-call flag checks via install_hook; beginTransaction and rollBack added as new traced methods
metadata/supported-configurations.json — document both variables
tests/Integrations/PDO/PDOTest.php — regression tests for both flags
Summary
Add two complementary PHP PDO configuration variables that mirror the Go tracer's
WithIgnoreQueryTypes()options:DD_TRACE_PDO_PREPARED_STATEMENTS_ENABLED— suppressPDO.prepare+PDOStatement.executespansDD_TRACE_PDO_LIFECYCLE_COMMANDS_ENABLED— suppress connection and transaction lifecycle spansMotivation
The Go tracer exposes fine-grained control over which DB operation types are traced via
WithIgnoreQueryTypes(QueryType...). PHP had no equivalent. In high-throughput applications:PDO.prepare+ execute) can generate noise when the query text is already visible onPDO.exec/PDO.query__construct,beginTransaction,commit,rollBack) have low diagnostic value in normal operation but contribute to trace volumeBoth flags follow the same pattern already established for Redis (
DD_TRACE_REDIS_LIFECYCLE_COMMANDS_ENABLED).Go tracer equivalence
DD_TRACE_PDO_PREPARED_STATEMENTS_ENABLED=falseWithIgnoreQueryTypes(QueryTypePrepare)DD_TRACE_PDO_LIFECYCLE_COMMANDS_ENABLED=falseWithIgnoreQueryTypes(QueryTypeConnect, QueryTypeBegin, QueryTypeCommit, QueryTypeRollback)Note: unlike Go (code-level option), PHP exposes these as environment variables — configurable without redeployment.
Behaviour
DD_TRACE_PDO_PREPARED_STATEMENTS_ENABLEDtrue(default)falsePDO.preparePDOStatement.executePDO.exec/PDO.queryDD_TRACE_PDO_LIFECYCLE_COMMANDS_ENABLEDtrue(default)falsePDO.__constructPDO.connectPDO.beginTransactionPDO.commitPDO.rollBackPDO.exec/PDO.query/ prepared statementsNote: connection metadata (
out.host,db.system, etc.) is always preserved viaObjectKVStoreso data command spans keep their tags regardless of the lifecycle flag.Implementation scope
ext/configuration.h— two newCONFIG(BOOL, ...)declarationssrc/DDTrace/Integrations/PDO/PDOIntegration.php— per-call flag checks viainstall_hook;beginTransactionandrollBackadded as new traced methodsmetadata/supported-configurations.json— document both variablestests/Integrations/PDO/PDOTest.php— regression tests for both flags