Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(otelgorm): Make metric reporting work with prepared statements #129

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

magnusbaeck
Copy link
Contributor

Previously we only initialized metrics reporting by calling otelsql.ReportDBStatsMetrics if the gorm.DB.ConnPool interface pointer we received happened to be a *sql.DB. This was often the case, but not if prepared statements were enabled (and possibly in other circumstances too). This caused metrics reporting to be silently disabled. We fix this by calling gorm.DB.DB whose sole purpose is to extract the underlying *sql.DB.

Previously we only initialized metrics reporting by calling
otelsql.ReportDBStatsMetrics if the gorm.DB.ConnPool interface
pointer we received happened to be a *sql.DB. This was often
the case, but not if prepared statements were enabled (and
possibly in other circumstances too). This caused metrics
reporting to be silently disabled. We fix this by calling
gorm.DB.DB whose sole purpose is to extract the underlying
*sql.DB.
@vmihailenco
Copy link
Member

Thanks

@vmihailenco vmihailenco merged commit aeefc42 into uptrace:main Jun 13, 2024
2 checks passed
@magnusbaeck magnusbaeck deleted the connpool-sql-db branch June 13, 2024 20:32
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.

2 participants