Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apmgormv2 postgres is not adding spans to http transactions #1596

Open
pkrauss-prot opened this issue Mar 18, 2024 · 1 comment
Open

apmgormv2 postgres is not adding spans to http transactions #1596

pkrauss-prot opened this issue Mar 18, 2024 · 1 comment
Labels

Comments

@pkrauss-prot
Copy link

pkrauss-prot commented Mar 18, 2024

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.

Screenshot from 2024-03-18 16-45-15

double checked the request object to make sure the transaction information was present and it is

Screenshot from 2024-03-18 16-53-29

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.

@pkrauss-prot
Copy link
Author

Also digging a little deeper when i use db.WithContext(r.Context()) i do see information populates in the transaction:

Screenshot from 2024-03-19 09-39-22

yet as i said, nothing shows up in apm under the transaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant