mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-30 00:36:14 -06:00
refactor: combine tracing & metrics in observability package
This commit is contained in:
parent
42e32eb57f
commit
826c36f162
10 changed files with 64 additions and 81 deletions
|
|
@ -41,9 +41,8 @@ import (
|
|||
"github.com/superseriousbusiness/gotosocial/internal/db/bundb/migrations"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/metrics"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/observability"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/state"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/tracing"
|
||||
"github.com/uptrace/bun"
|
||||
"github.com/uptrace/bun/dialect"
|
||||
"github.com/uptrace/bun/dialect/pgdialect"
|
||||
|
|
@ -324,11 +323,10 @@ func bunDB(sqldb *sql.DB, dialect func() schema.Dialect) *bun.DB {
|
|||
|
||||
// Add our SQL connection hooks.
|
||||
db.AddQueryHook(queryHook{})
|
||||
if config.GetTracingEnabled() {
|
||||
db.AddQueryHook(tracing.InstrumentBun())
|
||||
}
|
||||
if config.GetMetricsEnabled() {
|
||||
db.AddQueryHook(metrics.InstrumentBun())
|
||||
metricsEnabled := config.GetMetricsEnabled()
|
||||
tracingEnabled := config.GetTracingEnabled()
|
||||
if metricsEnabled || tracingEnabled {
|
||||
db.AddQueryHook(observability.InstrumentBun(tracingEnabled, metricsEnabled))
|
||||
}
|
||||
|
||||
// table registration is needed for many-to-many, see:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue