-
Notifications
You must be signed in to change notification settings - Fork 172
feat(pdo): add DD_TRACE_PDO_PREPARED_STATEMENTS_ENABLED and DD_TRACE_PDO_LIFECYCLE_COMMANDS_ENABLED #3751
Copy link
Copy link
Open
Description
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 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 onPDO.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 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels