Documentation ¶
Overview ¶
Package instagorm provides instrumentation for the gorm library.
Example ¶
// (c) Copyright IBM Corp. 2023 //go:build go1.18 // +build go1.18 package main import ( instana "github.com/instana/go-sensor" "github.com/instana/go-sensor/instrumentation/instagorm" "gorm.io/driver/sqlite" "gorm.io/gorm" ) func main() { s := instana.NewSensor("go-sensor-gorm") dsn := "<DSN information for database>" db, err := gorm.Open(sqlite.Open(dsn), &gorm.Config{}) if err != nil { panic("failed to connect database") } instagorm.Instrument(db, s, dsn) if err = db.AutoMigrate(&student{}); err != nil { panic("failed to migrate the schema") } db.Create(&student{Name: "Alex", RollNumber: 32}) } type student struct { gorm.Model Name string RollNumber uint }
Output:
Index ¶
Examples ¶
Constants ¶
View Source
const Version = "1.16.0"
Version is the instrumentation module semantic version
Variables ¶
This section is empty.
Functions ¶
func Instrument ¶
func Instrument(db *gorm.DB, s instana.TracerLogger, dsn string)
Instrument adds instrumentation for the specified gorm database instance.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.