Skip to content

Datastore segment unable to end when query parameters enabled (nrpgx5) #1017

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

Open
daffinito opened this issue Mar 28, 2025 · 0 comments
Open
Labels

Comments

@daffinito
Copy link

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))
@daffinito daffinito added the bug label Mar 28, 2025
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