I suspect the attributes provided to OpenDB are being dropped inside sqlOpenDB when setting up db.Stats reporting via ReportDBStatsMetrics.
func sqlOpenDB(connector driver.Connector, instrum *dbInstrum) *sql.DB {
db := sql.OpenDB(connector)
ReportDBStatsMetrics(db, WithMeterProvider(instrum.meterProvider))
return db
}
should probably look something like this
func sqlOpenDB(connector driver.Connector, instrum *dbInstrum) *sql.DB {
db := sql.OpenDB(connector)
ReportDBStatsMetrics(db, WithMeterProvider(instrum.meterProvider), WithAttributes(instrum.attrs))
return db
}
I'm not seeing the db.system label on any of the db.Stats metrics but it is still present as expected on the query.timing metric that comes from the tracing collection.
My current workaround is to direct register the db.Stats collection with ReportDBStatsMetrics but that doesn't disable the automatic collection started by OpenDB.
I suspect the attributes provided to
OpenDB
are being dropped insidesqlOpenDB
when setting updb.Stats
reporting viaReportDBStatsMetrics
.should probably look something like this
I'm not seeing the
db.system
label on any of thedb.Stats
metrics but it is still present as expected on thequery.timing
metric that comes from the tracing collection.My current workaround is to direct register the
db.Stats
collection withReportDBStatsMetrics
but that doesn't disable the automatic collection started byOpenDB
.