elastic / elastic/apm-agent-php

PDO auto-instrumentation reports span.subtype = unknown_DB for Pdo\Pgsql (and other PDO subclasses) on PHP 8.4

Open
#1,475 1 comment 1 reaction 0 assignees View on GitHub
agent-php bug
Dominant language
PHP
Stars
268
Forks
86
PR merge metrics
No merged PRs in 30d

Description

**Environment**

PHP 8.4.19
apm-agent-php 1.15.1
Laravel 13.14.0
PostgreSQL via ext-pdo_pgsql

**Describe the bug**
After upgrading to PHP 8.4, DB spans in Kibana APM show span.subtype = unknown_DB instead of postgresql. Service Map no longer shows PostgreSQL as a dependency. Redis spans are unaffected.

**To Reproduce**

1. PHP 8.4 + ext-pdo_pgsql + apm-agent-php 1.15.1
2. Run:
```
$pdo = PDO::connect('pgsql:host=localhost;dbname=test', 'user', 'pass');
$pdo->query('SELECT 1');
```
3. Open the resulting DB span in Kibana APM.

**Expected behavior**
span.subtype = "postgresql", connection visible as PostgreSQL dependency in Service Map.

**Actual behavior**
span.subtype = "unknown_DB".

**Possible cause**
PHP 8.4 introduced driver-specific PDO subclasses ([RFC](https://wiki.php.net/rfc/pdo_driver_specific_subclasses)) — new PDO('pgsql:...') now returns a Pdo\Pgsql instance instead of plain PDO. The agent hooks PDO methods by the hardcoded class name 'PDO', so the constructor interceptor does not fire on the subclass, the DSN is never parsed, and dbType falls back to unknown_DB. Likely affects all PHP 8.4 PDO subclasses (Pdo\Mysql, Pdo\Sqlite, etc.).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.