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

Feature request: spec support for using bound parameters as attribute values #245

Open
mitchsw opened this issue May 16, 2023 · 0 comments

Comments

@mitchsw
Copy link

mitchsw commented May 16, 2023

Would it be feasible to support attribute values being specified via a query's parameter bindings?

Idea

I'd like to support prepared statements like the following (and stay within the sqlcommeter spec):

LOG:  execute my-demo-stmt: SELECT * FROM FOO WHERE ID = $1 /*application='app-1', traceparent=$2*/
DETAIL:  parameters: $1 = 1234, $2 = '00-5bd66ef5095369c7b0d1f8f4bd33716a-c532cb4098ac3dd2-01'

This would necessitate an extension to sqlcommeter spec. Something like:

FIELD      ::=  <SERIALIZED_KEY>=<VALUE>
VALUE      ::=  <SERIALIZED_VALUE> | <PARAM_NUM>
PARAM_NUM  ::=  $[0-9]+

Motivation

My objective is to enable the performance benefits of prepared statements, whilst still being able to use a unique per-query traceparent.

In Postgres, it is technically possible to prepare and execute a statement like the example above. (The $2 parameter is simply unused by the query planner, but still appears in the statement log.) I am exploring adding this support to DataDog/dd-trace-go's SqlCommeter.

Would this feature in the spec be generally useful?

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

No branches or pull requests

1 participant