uptrace / opentelemetry-go-extra

OpenTelemetry instrumentations for Go
https://uptrace.dev/get/instrument/
BSD 2-Clause "Simplified" License
314 stars 72 forks source link

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

Closed magnusbaeck closed 4 months ago

magnusbaeck commented 4 months ago

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 commented 4 months ago

Thanks