Skip to content

fix(tracing): map database driver names to OpenTelemetry db.system values#1146

Open
dfinchenko wants to merge 1 commit into
getsentry:masterfrom
dfinchenko:fix-db-system-otel-naming
Open

fix(tracing): map database driver names to OpenTelemetry db.system values#1146
dfinchenko wants to merge 1 commit into
getsentry:masterfrom
dfinchenko:fix-db-system-otel-naming

Conversation

@dfinchenko

Copy link
Copy Markdown

Issue

Fixes #1075.

Database query spans set db.system directly from Laravel's driver name:

'db.system' => $query->connection->getDriverName(),

getDriverName() returns Laravel's driver identifiers (pgsql, sqlsrv, …), but Sentry's Queries insights filter spans by their OpenTelemetry db.system value, which does not include pgsql. As reported in #1075, this leaves the Queries table empty on a self-hosted instance even though the per-minute/duration graphs populate.

Change

Map the Laravel driver name to its OpenTelemetry db.system value before setting it on the span:

Laravel driver db.system
pgsql postgresql
sqlsrv mssql
mysql, mariadb, sqlite, … unchanged (passthrough)

This matches the direction confirmed by @Litarnus in the issue. Driver names that already equal the OpenTelemetry value are passed through unchanged, so only PostgreSQL and SQL Server change.

Tests

DatabaseIntegrationTest now asserts the mapped db.system for PostgreSQL and SQL Server connections, and the existing MySQL/SQLite cases assert the passthrough value. Full suite green (composer cs-check / composer tests).

Notes

  • Kept PHP 7.2 compatible (plain switch).
  • sqlsrv is mapped to mssql (the long-standing OpenTelemetry db.system value); happy to switch it to microsoft.sql_server if you prefer the newer registry name.
  • Did not touch CHANGELOG.md per the repo's agent guidance that it is release-managed — let me know if you'd like an Unreleased entry added.

Comment thread src/Sentry/Laravel/Tracing/EventHandler.php Outdated
@dfinchenko
dfinchenko force-pushed the fix-db-system-otel-naming branch from b061e2a to cf0c12e Compare June 19, 2026 18:30
…lues

Sentry's Queries insights filter database spans by their OpenTelemetry
db.system value, which does not recognize some of Laravel's driver names
(e.g. pgsql or sqlsrv), leaving the Queries table empty. Map the driver
name to the OpenTelemetry value (pgsql -> postgresql,
sqlsrv -> microsoft.sql_server), passing already-correct names
(mysql, mariadb, sqlite) through unchanged.

Fixes getsentry#1075
@dfinchenko
dfinchenko force-pushed the fix-db-system-otel-naming branch from cf0c12e to d96b8b0 Compare June 19, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong db.system as per OTeL naming convention

1 participant