feat(database): add automatic connection attribute extraction - #9
Merged
Merged
Conversation
- Parse DSN to extract server.address, server.port, db.user, db.name - Support PostgreSQL, MySQL DSN formats - Use OpenTelemetry semantic conventions v1.25.0 (server.address replaces net.peer.name) - Add comprehensive integration test for connection attributes - Update README with connection attributes documentation This enables better observability by automatically capturing: - Database host and port information - User information - Database name All attributes follow OTel semantic conventions for consistency. Benefits: - Better filtering and querying of database spans - Connection tracking across replicas/shards - Improved troubleshooting capabilities - Zero configuration required - works automatically from DSN Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
karthikeyangs9
approved these changes
Feb 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Automatically extracts database connection attributes from DSN (Data Source Name) and adds them to OpenTelemetry spans following semantic conventions v1.25.0.
Problem
Database spans were missing crucial connection metadata:
server.address(replaces deprecatednet.peer.name)server.portdb.userdb.nameThis made it difficult to:
Solution
Added DSN parsing functions that automatically extract connection attributes.
Changes
integrations/database/database.goOpen()tests/integration/database_test.goTestDatabase_ConnectionAttributesserver.address,server.port,db.user,db.name,db.systemREADME.mdTesting
✅ All existing tests pass
✅ New integration test validates connection attributes
Benefits
✅ Zero configuration - Works automatically from DSN
✅ OTel compliant - Uses semantic conventions v1.25.0
✅ Better observability - Full connection metadata in every span
🤖 Co-Authored-By: Claude Sonnet 4.5