opentelemetry-js-contrib
opentelemetry-js-contrib copied to clipboard
Add custom attributes to SQLCommenter comments in pg instrumentation
Is your feature request related to a problem? Please describe
Support for attaching SQLComment comments to SQL statements handled by the pg module was recently added in https://github.com/open-telemetry/opentelemetry-js-contrib/pull/1286. This issue proposes adding support for custom attributes to the SQL comments, besides tracestate and traceparent, which are now automatically generated by pg instrumentation (if the addSqlCommenterCommentToQueries config is enabled).
Examples of the custom attributes (as suggested by the spec) are action, controller, framework and route.
Describe the solution you'd like to see
As suggested in https://github.com/open-telemetry/opentelemetry-js-contrib/pull/1286#issuecomment-1375196941, one approach would be to allow the instrumentation to extract the custom attributes from the active context when a query is run (perhaps controlled by another config option). With this approach, one question that comes to mind is whether or not the attributes should be changeable from span to span.
Describe alternatives you've considered
Not using pg instrumentation to handle SQLCommenter comments, and instead appending the comments myself, where I can add whichever attributes I'd like.
Additional context
I'm creating this issue to get some thoughts on:
- whether or not this makes sense for pg instrumentation
- if 1, what approach would be best for implementing this
- if 1 and 2, pointers on where to get started so I or someone else can get started on a PR
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.
Don't close.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.
This issue was closed because it has been stale for 14 days with no activity.
@joelmukuthu did you ever find a solution to this?