-
Notifications
You must be signed in to change notification settings - Fork 311
Open
Labels
Description
Description
When query parameters are enabled, I am seeing the following error on a valid db query when trying to instrument with nrpgx5 integration:
{"level":"error","msg":"unable to end datastore segment","context":{"collection":"mytable","operation":"select","product":"Postgres","reason":"attribute '$0' value of type []string is invalid"}}
Steps to Reproduce
The postgres connection is implemented like this:
cfg.BeforeConnect = func(_ context.Context, config *pgx.ConnConfig) error {
config.Tracer = nrpgx5.NewTracer()
return nil
}
conn, err := pgxpool.NewWithConfig(context.Background(), cfg)
and the query is being made like this:
ctx := newrelic.NewContext(context.Background(), txn)
rows, err := db.Query(
ctx,
"SELECT id FROM mytable WHERE id = ANY ($1)", ids,
)
ids looks like this for example: []string{"1", "2", "3", "4" }
Expected Behavior
The query is able to be instrumented with query parameters enabled
NR Diag results
N/A
Your Environment
Go version 1.23
Using the latest pgxv5, agent and integration versions:
github.com/jackc/pgx/v5 v5.7.4
github.com/newrelic/go-agent/v3 v3.38.0
github.com/newrelic/go-agent/v3/integrations/nrpgx5 v1.3.0
Reproduction case
Additional context
Workaround: Disable query parameters.
I found that if I disable query parameters, the error goes away:
config.Tracer = nrpgx5.NewTracer(nrpgx5.WithQueryParameters(false))
gson-liang-eslite