database

package
v1.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const PluginName = "goravel:telemetry"

Variables

This section is empty.

Functions

func ContextWithTable

func ContextWithTable(ctx context.Context, table string) context.Context

ContextWithTable tags ctx with the collection a query targets so the wrapped builder can set db.collection.name for structured queries. Raw SQL omits it.

func Enabled

func Enabled(config config.Config) bool

func WrapBuilder

func WrapBuilder(inner contractsdb.Builder, inst *Instrument) contractsdb.Builder

WrapBuilder wraps a query builder with telemetry. The wrapper resolves telemetry lazily and no-ops until it is active.

func WrapTxBuilder

func WrapTxBuilder(inner contractsdb.TxBuilder, inst *Instrument) contractsdb.TxBuilder

WrapTxBuilder wraps a transaction builder with telemetry.

Types

type GormPlugin

type GormPlugin struct {
	// contains filtered or unexported fields
}

func NewGormPlugin

func NewGormPlugin(instrument *Instrument) *GormPlugin

func (*GormPlugin) Initialize

func (r *GormPlugin) Initialize(db *gorm.DB) error

func (*GormPlugin) Name

func (r *GormPlugin) Name() string

type Instrument

type Instrument struct {
	// contains filtered or unexported fields
}

func NewInstrument

func NewInstrument(pool contractsdatabase.Pool, connection string, resolver contractstelemetry.Resolver) *Instrument

func (*Instrument) SetDB

func (r *Instrument) SetDB(db *sql.DB)

SetDB stores the primary writer's *sql.DB for pool metrics. Pool metrics cover the writer pool only; dbresolver replica pools are internal gorm.ConnPool instances with no public sql.DBStats access.

func (*Instrument) Shutdown

func (r *Instrument) Shutdown()

Shutdown unregisters the pool-metrics callback and clears the resolved telemetry so the next use re-resolves against the current provider.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL