apm-agent-go
apm-agent-go copied to clipboard
apmgormv2 postgres is not adding spans to http transactions
Describe the bug I am using a combination of:
github.com/go-chi/chi/v5 v5.0.12 with go.elastic.co/apm/module/apmchiv5/v2 v2.5.0 gorm.io/gorm v1.25.5 with go.elastic.co/apm/module/apmgormv2/v2 v2.5.0
go.elastic.co/apm/module/apmsql/v2 v2.5.0 // indirect go.elastic.co/apm/v2 v2.5.0 // indirect
When i pass my DB object to my handlers I call .WithContext()
using r *http.Request
passed from chi to the handler. I am able to see the dependency for postgress and some metrics. However I am unable to see the spans in the http requests.
double checked the request object to make sure the transaction information was present and it is
To Reproduce Steps to reproduce the behaviour:
var database, _ = gorm.Open(postgres.Open("dsn"), &gorm.Config{})
func handler(w http.ResponseWriter, r *http.Request) error {
var projects []models.Project
var responseWrapper models.ResponseWrapper[[]models.Project]
database.WithContext(r.Context()).Preload(clause.Associations).Order("Name").Find(&projects)
if len(projects) > 0 {
responseWrapper.Data = projects
} else {
responseWrapper.Data = []models.Project{}
}
w.WriteHeader(http.StatusOK)
w.Write(responseWrapper.Marshal())
return nil
}
Expected behavior I would expect to see spans in the http transactions for my database queries.
Also digging a little deeper when i use db.WithContext(r.Context())
i do see information populates in the transaction:
yet as i said, nothing shows up in apm under the transaction.