You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 29, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on May 29, 2026. It is now read-only.
Feature request: spec support for using bound parameters as attribute values #245
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?
Reacted by Alex Normand, Eric Madar and Josh Hayes-Sheen
Yes! This feature would be quite useful for many applications!
AFAICT, Sqlcommenter currently acts as a post-processor that adds some comments to queries that later can be identified by the server to tag queries with extra metadata.
At least for PostgreSQL, when using prepared statements, the SQL text isn't sent to the server -- only the prepared statement name.
However (at least for PostgreSQL), I believe that it is possible to bind variables in comments like:
select1/*tracespan=$1*/
such that it can still be prepared, and a trace context can then be added at query execution time.
My specific use case is for the preferred Go PostgreSQL driver, pgx/v5, which exclusively uses prepared statements to achieve much better performance, but renders the current SQLCommenter utterly unusable.
@sjs994 @lonewolf3739 Is there any planned work to extend or amend the SQL Commenter spec using bound parameters in Prepared Statements, given the conversation in open-telemetry/semantic-conventions#2162
and in #284 ?
Activity
StevenACoffman commentedon Sep 28, 2025
Yes! This feature would be quite useful for many applications!
AFAICT, Sqlcommenter currently acts as a post-processor that adds some comments to queries that later can be identified by the server to tag queries with extra metadata.
At least for PostgreSQL, when using prepared statements, the SQL text isn't sent to the server -- only the prepared statement name.
However (at least for PostgreSQL), I believe that it is possible to bind variables in comments like:
such that it can still be prepared, and a trace context can then be added at query execution time.
My specific use case is for the preferred Go PostgreSQL driver, pgx/v5, which exclusively uses prepared statements to achieve much better performance, but renders the current SQLCommenter utterly unusable.
Please see jackc/pgx#1423
StevenACoffman commentedon Sep 28, 2025
@sjs994 @lonewolf3739 Is there any planned work to extend or amend the SQL Commenter spec using bound parameters in Prepared Statements, given the conversation in open-telemetry/semantic-conventions#2162
and in #284 ?
StevenACoffman commentedon Sep 29, 2025
@Thiyagu55 Do you have any thoughts on this?